Hi,
I am new to ASP.Net.
I have a website with Search Keyword form in header of all pages. When a visitor enters a keyword in input box and submits the form; on next page I want the text box to automatically fill the searched keyword.
Example:
[INDENT]<Form action=“search.aspx”>
[INDENT][INDENT] <INPUT type=“text” name=“txtKeyword” id=“txtKeyword” value=“” />
<INPUT type=“submit” value=“Submit” />[/INDENT][/INDENT]
</Form>[/INDENT]
Well, that depends on how you doing the redirect from the previous form. How are you posting the search term from the previous form?
It would generally be either a GET or POST method.
To load the textbox you can do this:
txtKeyword.Value = Request.QueryString[“txtKeyword”];
or
txtKeyword.Value = Request.Form[“txtKeyword”];
or you could just do the following that will work for both GET and POST params
txtKeyword.Value = Request[“txtKeyword”];
And all of these would be put in the pageLoad method.
I hope this helps
Note that the input text box is not ASP Textbox control.
Yes. I know it is not an ASP.NET textbox control. Thats why it is txtKeyword.Value if it was a ASP.NET textbox control you would set it with txtKeyword.Text