Forum Moderators: open
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.
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
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