473,714 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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).ToSt ring
lbtnCtrl.ToolTi p = dtrCal(10).ToSt ring & " these events"
& dtrCal(1)
lbtnCtrl.ID = "wecc" & i.ToString
lbtnCtrl.Comman dName = "WS"
lbtnCtrl.Comman dArgument = dtrCal(1)
AddHandler lbtnCtrl.Click, AddressOf cc_onClick
thsphcc.Control s.Add(ltrCtrl)
thsphcc.Control s.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 1857
Wouldn't you check the Page.IsPostBack in the Page_Load event?

If (!Page.IsPostBa ck)
{
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

"WebBuilder 451" <We***********@ discussions.mic rosoft.com> wrote in message
news:51******** *************** ***********@mic rosoft.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).ToSt ring
lbtnCtrl.ToolTi p = dtrCal(10).ToSt ring & " these
events"
& dtrCal(1)
lbtnCtrl.ID = "wecc" & i.ToString
lbtnCtrl.Comman dName = "WS"
lbtnCtrl.Comman dArgument = dtrCal(1)
AddHandler lbtnCtrl.Click, AddressOf cc_onClick
thsphcc.Control s.Add(ltrCtrl)
thsphcc.Control s.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.IsPostBa ck)
{
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

"WebBuilder 451" <We***********@ discussions.mic rosoft.com> wrote in message
news:51******** *************** ***********@mic rosoft.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).ToSt ring
lbtnCtrl.ToolTi p = dtrCal(10).ToSt ring & " these
events"
& dtrCal(1)
lbtnCtrl.ID = "wecc" & i.ToString
lbtnCtrl.Comman dName = "WS"
lbtnCtrl.Comman dArgument = dtrCal(1)
AddHandler lbtnCtrl.Click, AddressOf cc_onClick
thsphcc.Control s.Add(ltrCtrl)
thsphcc.Control s.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

"WebBuilder 451" <We***********@ discussions.mic rosoft.com> wrote in message
news:60******** *************** ***********@mic rosoft.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.IsPostBa ck)
{
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

"WebBuilder 451" <We***********@ discussions.mic rosoft.com> wrote in
message
news:51******** *************** ***********@mic rosoft.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).ToSt ring
> lbtnCtrl.ToolTi p = dtrCal(10).ToSt ring & " these
> events"
> & dtrCal(1)
> lbtnCtrl.ID = "wecc" & i.ToString
> lbtnCtrl.Comman dName = "WS"
> lbtnCtrl.Comman dArgument = dtrCal(1)
> AddHandler lbtnCtrl.Click, AddressOf cc_onClick
> thsphcc.Control s.Add(ltrCtrl)
> thsphcc.Control s.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
1666
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 i change the text displayed in the label in the same row. hier is my code: using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web;
2
16242
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. However, when i submit the page, i am unable to read the values entered in these new textboxes. I have first tried to use System.Web.UI.WebControls.TextBox namespace, however, i was unable to read any value from my textboxes using the following...
2
2555
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 and are called like a static control. Here is the problem that I need to solve. The processing overhead that occurs to determine what dynamic controls need to be added involves business logic and a query or queries of data in a sql server...
3
3979
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 step you're on. This all works fine, but I ran into some trouble when I started creating controls dynamically in my code-behind file. Each panel contains a table which is filled with various radio buttons, text fields and the such which are...
8
2014
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 for the button. (This is done by the form itself, not by using VS.Net) (button and source code should be a record in database, these information should be retrieve from database when the form shows up) What I want is:
0
1188
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 the code attached below. The sorting, paging also doesnt work. private void BuildDataGrid() {
13
10180
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 first order. Likewise if he clicks the second LinkButton, he will be shown the details of the second order he had placed. The Text of the LinkButtons will be 1 2 3 etc. So this user would see 1 2 3 4 5 as the LinkButtons. The problem is...
11
3281
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: <my:RoundedCornerBox id=foo runat=server>
5
3027
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 control creation and ViewState rehydration, and also let the checkbox click() event participate properly. Thanks.
0
8795
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8701
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9306
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9168
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9068
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5943
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4462
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4715
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2103
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.