Link to home
Start Free TrialLog in
Avatar of scooter1977
scooter1977

asked on

Passing a variable from a hyperlink

I have a list of static HTML that contains a list of users.  What I need to do is hyperlink each name and pass a string to a new page that will display user details.  On the Hyperlinks I have set a datanavigation url that has the query string /details.aspx?cn=tom but on the details page I'm not sure how to get that string.  

I know I need to access request.querystring but what is the easiest way to do that without having to put in a static entry for each user.  Can I just somehow access the variable part of the DataNavigationURL - (ie - tom)

BTW - I am using vb.net and asp 2.0
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

What do you mean by a "list of static HTML"?

Bob
If you can store that usernames into database than

1) create aspx with user list in datagrid.
2) Make their names as hyperlink
3) On selected index change event of gridview take the clicked button's text property and add it to query string parameters and than redirect to that page.

Avatar of scooter1977
scooter1977

ASKER

A list of users that is made of of static HTML like so:

<asp:hyperLink ID="HyperLink1" runat="server" NavigateUrl="~/details.aspx?cn=username">Tom Smith</asp:HyperLink>
        Title <br />
        Department<br />
        Additional Info<br />
       Phone #<br />
        <a href="mailto:Tom@domain.com">Email Tom </a>


How are you generating this HTML text?

Bob
it's just static HTML, it's not being generated from anywhere - I just need to know how to get the username from the  NavigateUrl="~/details.aspx?cn=username (which I set manually - it's not dynamic) into the details page with a request.querystring or whatever will work  

Normally I'd set the Request.quesrystring ("the field I want") but since there is no dynamic field for the username I don't know how to do it.



For example on Joe I have  NavigateUrl="~/details.aspx?cn=joe
on Jack I have  NavigateUrl="~/details.aspx?cn=jack
on Jill I have   NavigateUrl="~/details.aspx?cn=Jill

Does that make sense?
If you aren't generated this, then why don't you just hard code the values?

Bob
That's what I'm asking how to do ......   How do I get Joe, Jack, Jill, ect into my details page.....

On my details page I have a query that pulls info from a database based on cn=UserName

Example code please.   I'm not a .net coder so you're gonna have to help me out a little here
On every name links navigation url put like this.

for x
Details.aspx?user=x;

for y
Details.aspx?user=y;

Extract these values on the next page
ok......... so again.....how do I extract them on the next page.  I already have the values hard coded as I specified in my previous post

details.aspx?cn=joe
details.aspx?cn=jack
details.aspx?cn=Jill
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I need to get them into the next page.

Dim cn As String = Request.QueryString("cn")

Produces: The (cn=) search filter is invalid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: The (cn=) search filter is invalid.
If you consider  as i said than

string user = Request.QueryString("user");
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok - thank you chinu -  that's the part I was missing is that I had to do a request.querystring on each page.
Wait.

What you mean each page ? Each separate page for each user details ?
Is that what you doing ?