Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Button to pass string to aspx Webform 1

Status
Not open for further replies.

Programming2007

Programmer
Nov 10, 2006
24
US
Hello all I have a textbox that takes a string and when a button is clicked the string has to be passed to a method in an asp .net webform. How do I do this? below is my code.

Function in HOME.html (This is what I need help writing)!
<!--
function Button1_onclick() {
document.open("WebForm2.aspx");
WebForm2.keyWordSearch(txtSearch.value);
}

//-->
WebForm2.aspx
public void keyWordSearch(string s)
{
Response.Write(txtSearch.value);
}
 
You cannot call server-side methods from client-side code like that. You need to submit a form to your server-side code, and then read the values passed.

To get a client-side form submitting server-side, you would use something like this:

Code:
<form action="yourASPXURLhere.aspx" method="post">
   <input type="text" name="textField1" value="Some text" />
   <input type="submit" value="Submit this form" />
</form>

Then you would write the ASPX file to do the rest of the work. If you need to know how to pick up posted form values server-side, then you'd need to ask in the relevant .Net forum.

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top