473,782 Members | 2,485 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Postback or Click on Run-time created object

I have a database table of x elements. I need to loop through the database
table and add a checkbox for each entry to an asp:Table object. This I can
do.

Dim tRow As New TableRow
Dim tCell As New TableCell
Dim cbDT As New CheckBox
tblDTCodes.Rows .Add(tRow)
cbDT.Text = reader(0)
cbDT.Checked = False
tCell.Controls. Add(cbDT)
tRow.Cells.Add( tCell)

Question: How do I add a "Clicked" or "Checked" event to these new
checkboxes?

Question: If I can't do that, how do I interpret a PostBack from these
checkboxes?
May 5 '06 #1
4 3029
Answered my own question. The final resolution was this:
....
Dim cbDT As New CheckBox
cbDT.Text = reader(0)
cbDT.Checked = False
AddHandler cbDT.CheckChang ed, Addressof DTCode_Checked
....
with an event handler which looks like:

Public Sub DTCode_Checked( ByVal sender As Object, ByVal e As System.EventArg s)
Dim cdX As CheckBox = sender
....do something with it...
End Sub
"Herb" wrote:
I have a database table of x elements. I need to loop through the database
table and add a checkbox for each entry to an asp:Table object. This I can
do.

Dim tRow As New TableRow
Dim tCell As New TableCell
Dim cbDT As New CheckBox
tblDTCodes.Rows .Add(tRow)
cbDT.Text = reader(0)
cbDT.Checked = False
tCell.Controls. Add(cbDT)
tRow.Cells.Add( tCell)

Question: How do I add a "Clicked" or "Checked" event to these new
checkboxes?

Question: If I can't do that, how do I interpret a PostBack from these
checkboxes?

May 5 '06 #2
Herb wrote:
Answered my own question. The final resolution was this:
...
Dim cbDT As New CheckBox
cbDT.Text = reader(0)
cbDT.Checked = False
AddHandler cbDT.CheckChang ed, Addressof DTCode_Checked
...
with an event handler which looks like:

Public Sub DTCode_Checked( ByVal sender As Object, ByVal e As System.EventArg s)
Dim cdX As CheckBox = sender
...do something with it...
End Sub
"Herb" wrote:
I have a database table of x elements. I need to loop through the database
table and add a checkbox for each entry to an asp:Table object. This I can
do.

Dim tRow As New TableRow
Dim tCell As New TableCell
Dim cbDT As New CheckBox
tblDTCodes.Rows .Add(tRow)
cbDT.Text = reader(0)
cbDT.Checked = False
tCell.Controls. Add(cbDT)
tRow.Cells.Add( tCell)

Question: How do I add a "Clicked" or "Checked" event to these new
checkboxes?

Question: If I can't do that, how do I interpret a PostBack from these
checkboxes?

Remember, the event probably won't fire unless you re-add the control
before the page is rendered.
May 5 '06 #3
Re-add? I do see a lag in the operation. If I uncheck something, then submit
I get no results. If I submit again, then the change takes effect. Will
readding correct this?

"Ray Booysen" wrote:
Herb wrote:
Answered my own question. The final resolution was this:
...
Dim cbDT As New CheckBox
cbDT.Text = reader(0)
cbDT.Checked = False
AddHandler cbDT.CheckChang ed, Addressof DTCode_Checked
...
with an event handler which looks like:

Public Sub DTCode_Checked( ByVal sender As Object, ByVal e As System.EventArg s)
Dim cdX As CheckBox = sender
...do something with it...
End Sub
"Herb" wrote:
I have a database table of x elements. I need to loop through the database
table and add a checkbox for each entry to an asp:Table object. This I can
do.

Dim tRow As New TableRow
Dim tCell As New TableCell
Dim cbDT As New CheckBox
tblDTCodes.Rows .Add(tRow)
cbDT.Text = reader(0)
cbDT.Checked = False
tCell.Controls. Add(cbDT)
tRow.Cells.Add( tCell)

Question: How do I add a "Clicked" or "Checked" event to these new
checkboxes?

Question: If I can't do that, how do I interpret a PostBack from these
checkboxes?

Remember, the event probably won't fire unless you re-add the control
before the page is rendered.

May 5 '06 #4
Hi Herb,

When and where did you create those dynamic subcontrols and add them into
the table control on the page? As for dynamic controls, they need to be
added into control colleciton in each request(not only the initial request,
but also postback). Also, as for the postback event handlers, we need to
register them for the dynamic controls in each requests, and the
registering should take place before the page processing postback events.
So generally we're recommended to put the control creating and event
handler registering code in the Page's Init or Load event.

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
May 8 '06 #5

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

Similar topics

7
1492
by: Matt | last post by:
Hello, In an aspx page i have webform with some textboxes and a simple button. When the button is clicked, there is a postback and then the code in the click event of the button is executed. However in this code (click event of the button), i'm processing an online payment, which takes about 5 seconds. While waiting for the payment to be processed, the user can click again on the button, and this is what i want to block. I want to...
2
7214
by: Cindy | last post by:
Hi all you smarties out there, I'm having a little conundrum with my asp.net page Scenario: I have a form (asp.net) with no code behind (as yet). I have placed a javascript function on a server side textbox control to do something - eg change the words on label - when the key pressed is the "enter" key. I can see the label change to what i expect ----- BUT .... then the
4
1285
by: Mervin Williams | last post by:
Postbacks cause a webform to re-display the page at the top. Well, I have a fairly long form and would like the page display to be re-positioned where the user clicked the button that caused the postback to occur. Is there a way to do this? Mervin Williams
4
17110
by: Jeremy | last post by:
I have an ASPX page with a bunch of System.Web.UI.WebControls.Button controls on it. By default, clicking on any of these causes a Postback. I'd like to have it so that for a couple of these buttons, no PostBack occurs - and rather some client-side script is executed (with no postback subsequently occuring). I have wired up the client-side script to the Buttons in question using Attributes.Add(blah blah blah) - now I just need to somehow...
11
13951
by: CW | last post by:
I have message entry screen that's causing me a bit of an issue. At the moment, there are 2 buttons, one is used to send message to another user (btnSend) and another is used to send messages to all users (btnSendAll). When user hits enter, I also simulate the effect of clicking button (btnSend). However, what I found btnSend doesn't fire (unless I click on the button). The postback function I call is as follows: function...
2
2645
by: Alex | last post by:
In my Asp.net application, I have come across a situation where I cannot prevent a postback using the HtmlInputImage control. If I use the HtmlInputButton, the post back is not automatic, however with the HtmlInputImage, it appears to be. Add this to your aspx test app and set a breakpoint in your Page_Load. <input type="button" id="TheButton" value="GO"/> <input type="image" id="TheImage"/> When you click on the "TheButton" - no...
6
2438
by: SkeanDu | last post by:
Ok, here is my problem. I have an aspx page that displays a databound datagrid and in one of the datagrid column headers I have an image that when clicked opens up a modal web dialog (another aspx page). >From this dialog I want the users to be able to select a filter item from a databound combobox and click on the apply button on the web dialog that will then disappear and the filtered data will be displayed on my datagrid.
4
284
by: Johan | last post by:
I'm coding a webapp in VB.NET where I'm using a WebForm (Webform1) as the source for an Input Image to a second WebForm (Webform2). <INPUT style="Z-INDEX: 105; LEFT: 0px; POSITION: absolute; TOP: 0px" type="image" src="WebForm1.aspx" name="gamegrid"> I have a commandbutton on WebForm2 and when I click the comandbutton it gives a Postback to Webform1. This works fine when I run WebForm2 directly.
5
4288
by: TS | last post by:
Is there a way in debug mode to determine what event caused the postback to occur without having an event handler for that event? thanks
6
3419
by: RobGMiller | last post by:
Using ASP.NET 2.0 Need to simply process incoming postback information without sending back a reponse. Client sends HTML from application other than a browser to a page on a web site. Web Server ASP generates a response page and send it back which opens the browser on the client. How to avoid sending back the response page.
0
10313
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
10146
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
10080
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,...
1
7494
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
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
5378
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
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.