Request (Reference to) other page
-
I just started using WebMatrix and ASP.NET, and I have one problem - I like to know, how I can do it: Situation - I have one page "Licence agreement" with Agree and Disagree; when user click Agree, then must open Registration form (I made it in that way: Response.Redirect("Reg.aspx")). So far is OK! But I need, that the form Reg.aspx opens only when in Licence form users click Agree - shortly - it (Reg) should no opens, when users write in adress bar http://www.xxxxx.com/Reg.aspx... Sorry for my english, but I hope that U understood my problem. I use VB.NET
-
I just started using WebMatrix and ASP.NET, and I have one problem - I like to know, how I can do it: Situation - I have one page "Licence agreement" with Agree and Disagree; when user click Agree, then must open Registration form (I made it in that way: Response.Redirect("Reg.aspx")). So far is OK! But I need, that the form Reg.aspx opens only when in Licence form users click Agree - shortly - it (Reg) should no opens, when users write in adress bar http://www.xxxxx.com/Reg.aspx... Sorry for my english, but I hope that U understood my problem. I use VB.NET
Why not have them on the same page and skip the Agree/Disagree buttons. Put into your License Agreement that submitting a registration automatically agrees with license? But, you could drop a small flag into the Session object, in the Agree button click event, that is read by the Reg.aspx Page_Load event. In there, if the flag is not set, redirect them back to the License page. In your License page AgreeButton_Click handler:
Session("License") = "Accepted"
And in your Registration Page_Load event handler:
If Session("License") <> "Accepted" Then Response.Redirect("...URL to License Page...") End If
RageInTheMachine9532
-
Why not have them on the same page and skip the Agree/Disagree buttons. Put into your License Agreement that submitting a registration automatically agrees with license? But, you could drop a small flag into the Session object, in the Agree button click event, that is read by the Reg.aspx Page_Load event. In there, if the flag is not set, redirect them back to the License page. In your License page AgreeButton_Click handler:
Session("License") = "Accepted"
And in your Registration Page_Load event handler:
If Session("License") <> "Accepted" Then Response.Redirect("...URL to License Page...") End If
RageInTheMachine9532
I don't think using a session variable would be the best solution. I would do one of two things: (1) Check the page the user came from
If Request.ServerVariables("http_referer") <> "LicensePage.aspx" Then
' send user to another page or show an error
End IfOr... (2) Show/Hide panels upon agree/disagree
Within your ASPX page:<asp:Panel id="LicensePanel" runat="server">
...
<asp:Button id="AgreeButton" Text="Agree" runat="server" />
<asp:Button id="DisagreeButton" Text="Disagree" runat="server" />
</asp:Panel"><asp:Panel id="AgreePanel" Visible="false" runat="server">
You agreed! :)
</asp:Panel"><asp:Panel id="DisagreePanel" Visible="false" runat="server">
You disagreed! :(
</asp:Panel">And, within your
AgreeButton_Click
:LicensePanel.Visible = False
AgreePanel.Visible = TrueAnd, finally, within your
DisagreeButton_Click
:LicensePanel.Visible = False
DisagreePanel.Visible = TrueNow, personally, I'd prefer the second option over the first, but that kind of depends on how much functionality you want on the page. I'll leave that up to you. Hope this helps! Michael Flanakin Web Log
-
I don't think using a session variable would be the best solution. I would do one of two things: (1) Check the page the user came from
If Request.ServerVariables("http_referer") <> "LicensePage.aspx" Then
' send user to another page or show an error
End IfOr... (2) Show/Hide panels upon agree/disagree
Within your ASPX page:<asp:Panel id="LicensePanel" runat="server">
...
<asp:Button id="AgreeButton" Text="Agree" runat="server" />
<asp:Button id="DisagreeButton" Text="Disagree" runat="server" />
</asp:Panel"><asp:Panel id="AgreePanel" Visible="false" runat="server">
You agreed! :)
</asp:Panel"><asp:Panel id="DisagreePanel" Visible="false" runat="server">
You disagreed! :(
</asp:Panel">And, within your
AgreeButton_Click
:LicensePanel.Visible = False
AgreePanel.Visible = TrueAnd, finally, within your
DisagreeButton_Click
:LicensePanel.Visible = False
DisagreePanel.Visible = TrueNow, personally, I'd prefer the second option over the first, but that kind of depends on how much functionality you want on the page. I'll leave that up to you. Hope this helps! Michael Flanakin Web Log
Just something off the top of my head. I haven't been doing much ASP.NET so my solution most likely isn't the best, but it works... Your solutions are much better. Thanks for the tips! :-D RageInTheMachine9532
-
Just something off the top of my head. I haven't been doing much ASP.NET so my solution most likely isn't the best, but it works... Your solutions are much better. Thanks for the tips! :-D RageInTheMachine9532
Both of our solutions will work just fine. Using session variables, however, could lead to scalability problems in the long run. It's best to try to avoid them as a good practice. Michael Flanakin Web Log