Welcome to WebmasterWorld Guest from 54.221.131.67

Forum Moderators: ocean10000

Message Too Old, No Replies

Need help passing a url to a portal page

ASP.NET newbie can't find answer

     
7:52 pm on Jul 23, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 11, 2005
posts: 76
votes: 0


I've been searching for several days, but I have not found a good example of how to do this.

I have a page with multiple different links to a database driven sub site that look something like this:

href="sales/default.aspx?category_id=657230A7-37AB-4A62-8C77-2B39A78BEF3E&ControlName=SubCategories"

I want to pass this URL to a validation page the first time a user clicks one of these links in a session. On subsequent clicks, I want to bypass the validation page and follow the link directly.

I can't figure out how to pass the URL dynamically. I'm using the following code from the 4GuysFromRolla website

<asp:checkbox id="agree" runat="server"  
Text="Please check here to agree"></asp:checkbox>

<cc1:CheckBoxValidator ID="CheckBoxValidator1" runat="server"  
ControlToValidate="agree" Display="Dynamic"
ErrorMessage=" You must agree" ValidationGroup="Box">*</cc1:CheckBoxValidator>

<asp:Button ID="submit" runat="server" Text="Continue"  
ValidationGroup="Box" />

The code behind page is:

Partial Class _Default 
Inherits System.Web.UI.Page

Protected Sub SubmitFirstDemo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submit.Click 
'If the page is valid, send user to done.htm
If Page.IsValid() Then
Response.Redirect("done.htm")
End If
End Sub
End Class

So the question is, how do I turn the URL into a variable that is passed to the Response.Redirect object above?

I am guessing that I need to set a cookie to determine if the user has already clicked a link during the session, and I think I can figure out how to do this, unless someone can suggest a better way. Thanks.

1:19 am on July 24, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 11, 2005
posts: 76
votes: 0


I need to clarify that I am working with ASP.NET 2.0
Thanks.
7:02 am on July 25, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:732
votes: 0


Hi jdkuehne,

You could try the following:

In the onLoad event of the page, check a session variable to see if it has already been set, ie:


If Not Page.IsPostBack Then
if Session("hasAgreed") = true then
Response.Redirect("done.htm")
End If
End If

then, in the SubmitFirstDemo_Click event add the following:

If Page.IsValid() Then
Session.Add("hasAgreed", agree.Checked)
Response.Redirect("done.htm")
End If

* Edit: I haven't tested this code, but you get the general idea

8:59 pm on July 25, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 11, 2005
posts: 76
votes: 0


Thanks marcel, I need to ponder this. I appreciate your reply.