Can Href raise an event?

  • Thread starter Michael Tissington
  • 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?
 
G

Garett Rogers

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
 
G

Guest

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
 
M

Michael Tissington

Thanks - this is what I'm looking for but will this work with both IE and
Netscape ?
 
B

Bruno Sirianni

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
 
J

Jeffrey Tan[MSFT]

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.
 
V

Vidar Petursson

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 ?
 

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

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top