TheWizardofInt Posted February 18, 2003 Posted February 18, 2003 I use the postback method to force users to access through the login page. such that if postback = true, then you go to the login page Clicking any of the button forms sends the asp code to the page_load event, and the postback = true, so it wants to force the whole thing to reload from log in What am I doing wrong? Or is there a way to detect that I have clicked the button and then not go to the log in? Thanks! Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
*Experts* Bucky Posted February 18, 2003 *Experts* Posted February 18, 2003 I'm not sure I understand what you mean... The whole point of PostBack being true is so that you know the user pressed a button on the form and you can act accordingly. Maybe you should be checking if PostBack is False, instead? Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
*Gurus* Derek Stone Posted February 18, 2003 *Gurus* Posted February 18, 2003 Give each of the buttons handlers in their onclick events. Quote Posting Guidelines
TheWizardofInt Posted February 19, 2003 Author Posted February 19, 2003 I verified the handling, that wasn't it. Correct me if I am wrong on the other issue: If you haven't passed the start page, PastBack is True. Otherwise, it is false. Is there a way to detect if a button has been clicked? Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
justin Posted February 19, 2003 Posted February 19, 2003 You have to write an onclick event handler for every button you have. In design mode, just right click on the buton and choose properties, events, onclick. Be sure your button is an web control. Quote
TheWizardofInt Posted February 19, 2003 Author Posted February 19, 2003 I did this It didn't work Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
TheWizardofInt Posted February 19, 2003 Author Posted February 19, 2003 If you click the btnCancel, then it tries to reload the page, gets a post back and goes to the login page. If you manually push it to the end of the end if, it will go through the btnCancel subroutine Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then 'I have my code here Else Dim url As String url = "LogIn.aspx" Response.Redirect(url) End If End Sub Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click 'go back with the id you came in with Dim url As String url = "Main.aspx?id=" & Request("ID") Response.Redirect(url) End Sub Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
justin Posted February 20, 2003 Posted February 20, 2003 Try with this: <asp:button id=Cancel runat="server" Text="Cancel" ></asp:button> ___________________________________________________ /* Sorry, but I am not familiar with VB */ if (IsPostBack) {   bool clicked = false;   string BtnValue = Request.QueryString["Cancel"];   if (BtnValue != null)   {     if (BtnValue == "Cancel")       clicked = true;   }   if (clicked == false) /* not clicked */     Response.Redirect("Login.aspx"); } ___________________________________________________ Quote
TheWizardofInt Posted February 20, 2003 Author Posted February 20, 2003 I couldn't identify the clicked event in VB but I was able to pass a variable to the next page that gets me through this Thanks Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.