PostBack after AddHandler

M

Marina

You can't. This is just how things work. Restructure your code so that it
works the way you need it to. Put code you need to run in a separate method,
and then call it from both page_load when you need it, and from your event
handler if you need it there instead.
 
L

Luis Esteban Valencia Muñoz

Have a dropdownlist created in my LoadMain() which is called from the
Page_load:
************************PAGE LOAD********************8Private Sub
Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Try
'Initialize.
Main.SetBodyURL(Page)
conSess = MySession.Connection(Session)
objPP = MySession.ProdPres(Session, Req.ID(Request))
'Format header and footer.
ProdPresProperties.FormatHeader(Header1, objPP, "Create
Coordinated Set - Size", , , objPP.j_group_type =
ProdPres.GroupType.ENS.ToString)

'Load Page
LoadMain()


With ucCreateButtons
.CreateButton.Text = "Create"
.ResetButton.Text = "Undo"
End With

Catch ex As Exception
FailurePage.SetMessage(Header1, ex)
FailurePage.SetReturnURL(Page, Main.GetPrevURL(Page))
FailurePage.Show(Page)
End Try

End Sub
*******************END PAGE LOAD****************

**********LOAD MAIN ***************************
Private Sub LoadMain()
'Add DropDown List Items for ddlFunction
ddlFunction = New DropDownList
ddlFunction.AutoPostBack = True
ddlFunction.Items.Add(New ListItem("", "0"))
ddlFunction.Items.Add(New ListItem("NONE", "n"))
ddlFunction.Items.Add(New ListItem("ALWAYS", "a"))
ddlFunction.Items.Add(New ListItem("MULTIPLIER", "m"))

'Create AddHandler for ddlFunction
AddHandler ddlFunction.SelectedIndexChanged, AddressOf
ProcessDDLFunction


tr.Cells.Add(CreateDropDownListCell(ddlFunction,
"ddlFunction" & strText, , 85, Css.Style.DefaultText))

***************EN LOAD MAIN*************************

The problem that I am having is that when the SelecteIndex does get changed
the form process the Page_Load again and runs thru my LoadMain(). Then it
processes my AddHandler function. How can I get it to FIRST process the
AddHandler function, then process the Page_Load?
 

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,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top