Can Href raise an event?

  • Thread starter Thread starter Michael Tissington
  • Start date Start date
M

Michael Tissington

What is the best way of doing this ....

In my Page_Load event I am building a table with a number of <a> tags.

On the page I have a Text box control.

When the user clicks one of the <a> tags and they get href to another page
and then want to access the value of the Text box control.

Any ideas how to do this please?
 
One way to do this would be the following:
<a href="javascript:void(0);"
onclick="window.location.href='/destination/path.aspx?textboxvalue=' +
document.getElementById('TextBox1').value;">text link</a>

Then in the destination page, you can access the value of the text box by
using Request.Querystring.Item("textboxvalue") in the codebehind

Hope this helps,
Garett

http://www.aimx.com
There's no place like 127.0.0.1
 
Same idea as the first reply but doing it server-side using web server controls..

You could build your table using LinkButton controls instead of <a>...then you can use the click event of the LinkButton controls to access the TextBox control. Once you have the value from the TextBox, use it to build a link to the destination page by appending it. Then in the destination page, use Request.Querystring to access the value

LinkButton docs..

http://msdn.microsoft.com/library/d...s/cpgenref/html/cpconlinkbuttonwebcontrol.asp
 
Thanks - this is what I'm looking for but will this work with both IE and
Netscape ?
 
for nescape you can replace document.getElementById('TextBox1').value with
document.all['TextBox1'].value.

other solution is :
in table you can insert LinkButton instead <a/> tag. Add an event handler
for click, or better command, and do this work inside this.

private void link_click(object s, EventArgs e)
{
.....
Response.Redirect(".......aspx?val=" + TextBox1.Text);
}

Brun
 
Hi Michael,

Does the community's reply make sense to you? Do you still have concern on
this issue?

Please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi

Nop document.all is IE only...

This should work on most browsers

document.forms["FORMNAME"].ELEMENTNAME.value

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
Bruno Sirianni said:
for nescape you can replace document.getElementById('TextBox1').value with
document.all['TextBox1'].value.

other solution is :
in table you can insert LinkButton instead <a/> tag. Add an event handler
for click, or better command, and do this work inside this.

private void link_click(object s, EventArgs e)
{
.....
Response.Redirect(".......aspx?val=" + TextBox1.Text);
}

Brun

Michael Tissington said:
Thanks - this is what I'm looking for but will this work with both IE and
Netscape ?
 
Back
Top