passing hyperlink parameter

S

susie

I have the following code to pass user input from a text
box named textbox:

<asp:hyperlink id="hyperlink1" text="Print"
navigationurl="http://myserver/commericial.aspx?id=<%
=textbox.text%>" runat=server/>


First user enter an id into the textbox, then click on
Print link to be redirected to page commericial.aspx

I have the following restrictions:
The code can not be evoked from onblur event or
ontextchange event or can not be rewritten through a
button onclick event.

It has to be through the <asp:hyperlink..../>

I would like to someone offer suggestions on correct
syntax on navigationurl="http://myserver/commericial.aspx?
id=<%
=textbox.text%>"

I tried navigationurl="http://myserver/commericial.aspx?
id" & System.Web.HttpUtility.UrlEncode(Name.Text)

But this generate server tag not formatted right error.

Can anyone offer suggestion on the syntax for this line
of code?

Thank you!
 
K

Kelly Leahy

Are you getting the "use a different type of quotes"
message? If so, change your quotes around
navigationurl="..." to navigationurl='...'. The ASP
parser in VS.NET is picky about that.

If that's not the problem (like you aren't using VS) then
can you give a more detailed error message?
 
S

susie

The error message is
"The server tag is not well formed."

I am using Asp.net with VB script.
 
A

Alessandro Zifiglio

hi susan, textbox.text is supposed to be executed server side and not on the
client. The hyperlink control does not postback ;)

Your best bet right now would be to use a Link button control. This control
supports posts back to the server. Write your logic in the buttons click
event and redirect.
 
M

Mas Jabier

Sussie,

If the only error it gets is "The server tag is not well-
formed", you should put a '<%# some_address %>' in the
NavigateUrl params, like :

<asp:Hyperlink id="hyperlink1" Text="Print"
NavigateUrl='<%# "http://myserver/commericial.aspx?id=" &
textbox.Text%>' runat="server"/>
First user enter an id into the textbox, then click on
Print link to be redirected to page commericial.aspx

I have the following restrictions:
The code can not be evoked from onblur event or
ontextchange event or can not be rewritten through a
button onclick event.

This is impossible, because the Print Hyperlink
NvaigateURL property must be set first. If you want to
make dynamically after User Input, then you must use
Javascript to satisfy this like :
<script language="Javascript">
function goURL()
string txtTemp;
//get textbox id
txtTemp = _ctl0.textbox.value; //based on your code
//it should be ctlx,ctl1..
location.href="http://some_address?id=" + txtTemp;
</script>

<input type="button" value="Print" onClick="goURL()">


Hope this help :)

Jody Ananda
MCAD,MCSD.Net
 

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

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,161
Latest member
GertrudeMa
Top