Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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!

Read the Fovean Chronicles

Because you just can't spend your whole day programming!

  • *Experts*
Posted

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?

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Posted

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?

Read the Fovean Chronicles

Because you just can't spend your whole day programming!

Posted
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.
Posted

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

Read the Fovean Chronicles

Because you just can't spend your whole day programming!

Posted

Try with this:

 

<asp:button id=Cancel runat="server" Text="Cancel" ></asp:button>

 

___________________________________________________

 

/* Sorry, but I am not familiar with VB */

 

if (IsPostBack)

{

&nbsp&nbspbool clicked = false;

&nbsp&nbspstring BtnValue = Request.QueryString["Cancel"];

&nbsp&nbspif (BtnValue != null)

&nbsp&nbsp{

&nbsp&nbsp&nbsp&nbspif (BtnValue == "Cancel")

&nbsp&nbsp&nbsp&nbsp&nbsp&nbspclicked = true;

&nbsp&nbsp}

 

&nbsp&nbspif (clicked == false) /* not clicked */

&nbsp&nbsp&nbsp&nbspResponse.Redirect("Login.aspx");

}

 

___________________________________________________

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...