Simple NavigateURL, I Think

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Sorry, very Newbie question here. I don't know what I'm doing wrong. I have
to use a <asp:hyperlink> to go to another page. I want to pick up the value
in a text box. This is what I've tried and It tells me it won't work. Not
sure how to do it.

NavigateUrl="~/secure/Confirm.aspx?No=201, IDate=" & TxtBx1.text & ", ODate
= "
& TxtBx2.text


Thank you in advance.
 
Since the TextBox is a server control, your strategy will not get the
navigateUrl value to include the user entry until you post the form back to
the server. In which case, you should compose the NavigateUrl property upon
postback, e.g.

HyperLink1.NavigateUrl ="~/secure/Confirm.aspx?No=201, IDate=" + TxtBx1.text
& ", ODate= " & TxtBx2.text
 
On more aside note is that when composing querystring parameters you should
use the & instead of the commas as separators of parameters, e.g.

hl1.NavigateUrl = "~/secure/Confirm.aspx?No=201&IDate=" &
Server.HtmlEncode(TxtBx1.text) + "&ODate= " & Server.HtmlEncode(TxtBx2.text)

However, if you will compose the NavigateUrl on the server based on the
user's entry, you might as well consider using the Response.Redirect to
redirect the user's display to the requested page instead of just composing a
hyperlink on which the user still has to click on to navigate to the required
page.
 
Hi,

Thanks for your reply. The reason I've using a Hyperlink is because I want
them to click on an image with contains the link.

So if I understand properly, I can't refer to a text box through a hyperlink
unless I add it in code.


Thank you
 
Using the HyperLink control to display an image that can link to a URL is
quite alright. You just cannot compose its NavigateUrl property value from a
server control (such as the TextBox) without causing a round trip to the
server.

In programming for web applications, as opposed to desktop application, one
must understand the difference between the web server controls and the
objects that they render on the browser. The values that the user enter on
the objects displayed on the browser can be retrieved using the server
controls properties (such as the Text property of the TextBox) only when
posted back to the server; at which stage the ASP.NET engine constructs back
the server controls (e.g. the TextBox) from the browser objects.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top