I need some advice...

Our website has ASP.NET pages.  Each page contains 3 user controls for
navigation.  Within the 3 controls, and also within the main pages
themselves, there are numerous hyperlinks in which I need to embed a
shopping cart ID in the querystring.  We used to do this in classic ASP
like this...

     <a href="/product.asp?<%=ID%>">Product Link</a>

Now, using ASP.NET, what's the best way to do this?  Keep in mind that I
generate the ID in the Page_Init method of the first user control.  That
ID then needs to appear in all the other controls and the main page
itself.

One possible solution would be to generate the ID and then place it in
the Context.Items collection, like this...

     Context.Items["ID"] = strID;

...and then retrieve the ID in all the other controls and the page like
this...

     <a href="/product.asp?<%=Context.Items["ID"].ToString()%>">Product
Link</a>

This seems to work.  Are there any performance drawbacks?

Yet another solution would be to use data binding.  To do this, I think
I would place a line in the Page_Init method of the first user control
that looks something like this...

     string strID = objMyObject.GenerateID();
     DataBind();

...which would then bind the ID into all the hyperlinks in all the other
controls and the page, because the hyperlinks would have embedded data
binding expressions, like this...

     <a href="/product.asp?<%# strID %>Product Link</a>

I have not tried this, but it's supposed to work.  Any drawbacks?

Which if these two solutions is best?  Or is there yet another solution
that would be even better?  Please advise.  All feedback is greatly
appreciated.

- John

=========================
John A. Vieth
Web Developer
GEMPLER'S
1210 Fourier Dr.
Madison, WI 53717
[EMAIL PROTECTED]
(608) 662-3301, ext. 3547
=========================



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/17folB/TM
--------------------------------------------------------------------~-> 

---------------------------------------------------------------------    
 Home       : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
 Post       : [EMAIL PROTECTED]
 Subscribe  : [EMAIL PROTECTED]
 Unsubscribe: [EMAIL PROTECTED]
--------------------------------------------------------------------- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/active-server-pages/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to