dynamic controls creation issues

G

Guest

I have a series of dynamic link buttons created based upon a datareader. I've
added a click event and it calls the sub ok:
example: "while loop through the reader"
Dim ltrCtrl As New LiteralControl
Dim lbtnCtrl As New LinkButton
ltrCtrl.Text = "<br>"
lbtnCtrl.Text = "WE: " & dtrCal(10).ToString
lbtnCtrl.ToolTip = dtrCal(10).ToString & " these events"
& dtrCal(1)
lbtnCtrl.ID = "wecc" & i.ToString
lbtnCtrl.CommandName = "WS"
lbtnCtrl.CommandArgument = dtrCal(1)
AddHandler lbtnCtrl.Click, AddressOf cc_onClick
thsphcc.Controls.Add(ltrCtrl)
thsphcc.Controls.Add(lbtnCtrl)
"end"
I'm calling the sub (LOADBTNS) to create the linkbuttons in the page load sub.
I have a series of other non-dynamic link buttons that need to recreate the
dynamic linkbuttons by calling a query with a different value.
Is there a way to check in the page load to see if a specific event was
fired and therefore not call the LOADBTNS sub.
something like
if not me.lbtnNxt.[event fired]
Call LOADBTNS(CType(lblNow.Text, Date))
End If
or is there a different way to create dynamic buttons?
thanks
kes
 
G

Guest

both controls including the dynamic will causea post back. The problem is
that the create will get called twice if the static button is clicked.
i need a (not sloppy) way to check for a specific event.

Robbe Morris said:
Wouldn't you check the Page.IsPostBack in the Page_Load event?

If (!Page.IsPostBack)
{
build standard dynamic controls;
}
else
{
build the controls based on criteria or
build them in a different event.
}

--
2004 and 2005 Microsoft MVP C#
Robbe Morris
http://www.masterado.net

Earn $$$ money answering .NET Framework
messageboard posts at EggHeadCafe.com.
http://www.eggheadcafe.com/forums/merit.asp



WebBuilder451 said:
I have a series of dynamic link buttons created based upon a datareader.
I've
added a click event and it calls the sub ok:
example: "while loop through the reader"
Dim ltrCtrl As New LiteralControl
Dim lbtnCtrl As New LinkButton
ltrCtrl.Text = "<br>"
lbtnCtrl.Text = "WE: " & dtrCal(10).ToString
lbtnCtrl.ToolTip = dtrCal(10).ToString & " these
events"
& dtrCal(1)
lbtnCtrl.ID = "wecc" & i.ToString
lbtnCtrl.CommandName = "WS"
lbtnCtrl.CommandArgument = dtrCal(1)
AddHandler lbtnCtrl.Click, AddressOf cc_onClick
thsphcc.Controls.Add(ltrCtrl)
thsphcc.Controls.Add(lbtnCtrl)
"end"
I'm calling the sub (LOADBTNS) to create the linkbuttons in the page load
sub.
I have a series of other non-dynamic link buttons that need to recreate
the
dynamic linkbuttons by calling a query with a different value.
Is there a way to check in the page load to see if a specific event was
fired and therefore not call the LOADBTNS sub.
something like
if not me.lbtnNxt.[event fired]
Call LOADBTNS(CType(lblNow.Text, Date))
End If
or is there a different way to create dynamic buttons?
thanks
kes
 
T

Teemu Keiski

You certainly can check in Page_Load if certain control caused a postback,
it just means using Request.Form collection
http://blogs.aspadvice.com/joteke/archive/2004/08/05/1444.aspx

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke



WebBuilder451 said:
both controls including the dynamic will causea post back. The problem is
that the create will get called twice if the static button is clicked.
i need a (not sloppy) way to check for a specific event.

Robbe Morris said:
Wouldn't you check the Page.IsPostBack in the Page_Load event?

If (!Page.IsPostBack)
{
build standard dynamic controls;
}
else
{
build the controls based on criteria or
build them in a different event.
}

--
2004 and 2005 Microsoft MVP C#
Robbe Morris
http://www.masterado.net

Earn $$$ money answering .NET Framework
messageboard posts at EggHeadCafe.com.
http://www.eggheadcafe.com/forums/merit.asp



message
I have a series of dynamic link buttons created based upon a datareader.
I've
added a click event and it calls the sub ok:
example: "while loop through the reader"
Dim ltrCtrl As New LiteralControl
Dim lbtnCtrl As New LinkButton
ltrCtrl.Text = "<br>"
lbtnCtrl.Text = "WE: " & dtrCal(10).ToString
lbtnCtrl.ToolTip = dtrCal(10).ToString & " these
events"
& dtrCal(1)
lbtnCtrl.ID = "wecc" & i.ToString
lbtnCtrl.CommandName = "WS"
lbtnCtrl.CommandArgument = dtrCal(1)
AddHandler lbtnCtrl.Click, AddressOf cc_onClick
thsphcc.Controls.Add(ltrCtrl)
thsphcc.Controls.Add(lbtnCtrl)
"end"
I'm calling the sub (LOADBTNS) to create the linkbuttons in the page
load
sub.
I have a series of other non-dynamic link buttons that need to recreate
the
dynamic linkbuttons by calling a query with a different value.
Is there a way to check in the page load to see if a specific event was
fired and therefore not call the LOADBTNS sub.
something like
if not me.lbtnNxt.[event fired]
Call LOADBTNS(CType(lblNow.Text, Date))
End If
or is there a different way to create dynamic buttons?
thanks
kes
 

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,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top