Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
This is my Form Tag from The Master Page:

ASP.NET
<form id="form1" runat="server" action="Handler.ashx" method="POST" enctype="multipart/form-data">


I have a TextBox in my Content Page:

ASP.NET
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>


I want to access the TextBox value in the Handler.ashx page Or Send the TextBox value as a query string in the action attribute like this
ASP.NET
<form id="form1" runat="server" action="Handler.ashx?textBoxVal=SOMETHING" method="POST" enctype="multipart/form-data">


Is this possible?
Posted

1 solution

Try this

JavaScript
<script type="text/javascript">
  window.onload = function() {
	document.FormName.onsubmit = submitForm;
}

 function submitForm() {
	this.action = "http://Handler.ashx?textbox" + value;
}
</script>


C#
<form id="form1" runat="server" method="POST" enctype="multipart/form-data">
   
</form>


Refer this
http://stackoverflow.com/questions/2701041/how-to-set-form-action-through-javascript
http://tycoontalk.freelancer.com/javascript-forum/60860-javascript-change-form-post-action-url.html
 
Share this answer
 
Comments
Member 7781963 7-Dec-12 5:26am    
What is FormName here?
pradiprenushe 7-Dec-12 5:44am    
It is id or name of form replace statement with this
document.forms["form1"].submit();
Member 7781963 7-Dec-12 5:45am    
where do i use this script?? Master Page or Content Page??
pradiprenushe 7-Dec-12 5:49am    
In master page & to get textbox from content page
refer this link
http://forums.asp.net/t/1400676.aspx/1
Member 7781963 7-Dec-12 6:01am    
I tried your solution , but i get the Content Page Name(action="Album.aspx") in the action attribute with your solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900