By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,666 Members | 1,784 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,666 IT Pros & Developers. It's quick & easy.

How set query arg and navigate to new page when button pressed?

P: n/a
<Newbie>

How can I get arguments, and build a query URL, before a button is pressed?

I have a text box to enter a serial number. When the search button is
pressed, I wish append the serial number text to the URL and navigate to
the search results page. I tried the button click event, but this does
not work until the second click. What is a better way to accomplish the
desired behavior?
private const string urlQuery = @"~/queryPage.aspx?serialNumber=";

protected void btnQuery_Click(object sender, EventArgs e)
{
btnQuery.PostBackUrl = urlQuery + txtSerialNumber.Text;
}

Thanks in advance for any tips or suggestions,

-Ed
Sep 14 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
If you want to do this prior to postback, you need some javascript. You can
set up the textbox in question (or button) with additional attributes and
then emit the javascript, if you feel uncomfortable working in the client
world, but that is the only way to automagically redirect someone without a
postback.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think Outside the Box!
*************************************************
"Ed Sutton" <de******************@hotmail.comwrote in message
news:uY**************@TK2MSFTNGP06.phx.gbl...
<Newbie>

How can I get arguments, and build a query URL, before a button is
pressed?

I have a text box to enter a serial number. When the search button is
pressed, I wish append the serial number text to the URL and navigate to
the search results page. I tried the button click event, but this does
not work until the second click. What is a better way to accomplish the
desired behavior?
private const string urlQuery = @"~/queryPage.aspx?serialNumber=";

protected void btnQuery_Click(object sender, EventArgs e)
{
btnQuery.PostBackUrl = urlQuery + txtSerialNumber.Text;
}

Thanks in advance for any tips or suggestions,

-Ed

Sep 15 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.