Problems wit events

N

Norbeto Mesen

Hi, everybody


I have a problem with the events in a web page.
I have a botton with a method that should execute a method on mouse click
but for some reason (that I don't know) it is executing the page_Load before
the method call, WHY?
What I need is that the method be called before any event and If its
possible to cancel the Page_Load, or where else I can set this code in the
button. This is what I have. The Page_Load always gets fired when I click
onm btnBuscar. Any ideas.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If IsPostBack Then
End If
End Sub


Private Sub btnBuscar_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnBuscar.Click
Dim condicion As String
condicion = ""
PrepareCondition(Page, condicion)
If condicion.Length <> 0 Then
condicion = " WHERE " & condicion.Substring(4)
End If
Session("tcWhere") = condicion
Response.Redirect("frmMansgrPoliza.aspx")
End Sub

Also I have another problem if i refresh the page with F5 function key, the
click event on the botton always gets re-executes.


Thanks ahead,
Norberto
 
R

Rich Mercer

The Page_Load event is always called before any control
event. Try placing your Page_Load code into a method and
call the method from Page_Load using the IsPostBack
property to only call it on the first page load then you
can call it from your controls event if you need to but
it wont execute after a post back.

HTH.

Rich Mercer
MCAD
 
N

Norberto Mesén López

Thank for your help

But I Also I have another problem if i refresh the page with F5 function
key, the click event on the botton always gets re-executes.

Thanks ahead,
Norberto
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top