473,410 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

dynamic controls creation issues

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
Nov 19 '05 #1
3 1836
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" <We***********@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com...
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

Nov 19 '05 #2
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 [C# MVP]" wrote:
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" <We***********@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com...
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


Nov 19 '05 #3
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/ar...8/05/1444.aspx

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

"WebBuilder451" <We***********@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.com...
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 [C# MVP]" wrote:
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" <We***********@discussions.microsoft.com> wrote in
message
news:51**********************************@microsof t.com...
>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
>
>


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: DotNetJunkies User | last post by:
Hie, I create a dynamique HtmlTable, in each cell of this HtmlTable put a new control ( dropdownlist,label,..) and then want to create handler so that if i change the select item in the dop downlist...
2
by: charliewest | last post by:
I need to create textboxes in real-time, the actual number of which is determine by a result from a database query. I have been able to create the controls, and then add them to the ASPX page....
2
by: Dave Williamson | last post by:
When a ASPX page is created with dynamic controls based on what the user is doing the programmer must recreate the dynamic controls again on PostBack in the Page_Load so that it's events are wired...
3
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
8
by: George Meng | last post by:
I got a tough question: The backgroud for this question is: I want to design an application works like a engine. After release, we can still customize a form by adding a button, and source code...
0
by: gokulrajad | last post by:
Hi there, Iam trying to create a datagrid dynamically in asp .net (C#). It contains a leftmost column with the check box and few data columns and the last column is a hyperlink column. Please find...
13
by: rn5a | last post by:
In a shopping cart app, suppose a user has placed 5 orders, I want to show him 5 LinkButtons (one for each order) so that when he clicks the first LinkButton, he would be shown the details of his...
11
by: Nick Gilbert | last post by:
Hi, How can I create a custom control which will wrap its content in a header and footer? eg: Is it possible to create a .NET user control which can surround other controls? eg:...
5
by: lucius | last post by:
Can someone provide a sample of how to add a new CheckBox control to an ASP.NET page, dynamically completely in code-behind? I am having a problem understanding which event should handle the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.