Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Dynamic Web Form Events


Message #1 by "Thomas Fuller" <tfuller@g...> on Fri, 19 Jul 2002 17:37:17
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C22F56.380FFCE0
Content-Type: text/plain

I guess my first question is if I have to pull all my existing code out to
be accessed from the page init how can I access what button is being clicked
on.  I currently have a Link Button that I click on and I handle that click
event by building the following and calling my create form sub routine.  So
if I need to call this from the page init I guess I need to have a way to
know what button was clicked on at that point in the page execution.  Is
there an easy way to do this (hopefully something like
lnkLoanTypes_Add.Value or lnkLoanTypes_Add.selected)?
 
    Private Sub lnkLoanTypes_Add_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles lnkLoanType_Add.Click
        phLoanTypes.Controls.Clear()
        Dim dtCustom As New DataTable()
        Dim drCustom As DataRow
 
        dtCustom.Columns.Add("FieldName", GetType(System.String))
        dtCustom.Columns.Add("dbFieldName", GetType(System.String))
        dtCustom.Columns.Add("dbFieldType", GetType(System.String))
        dtCustom.Columns.Add("dbFieldMax", GetType(System.Int32))
        dtCustom.Columns.Add("dbAllowNulls", GetType(System.Boolean))
        dtCustom.Columns.Add("InputType", GetType(System.String))
        dtCustom.Columns.Add("InputLabel", GetType(System.String))
        dtCustom.Columns.Add("ValidateQuery", GetType(System.String))
        dtCustom.Columns.Add("Query", GetType(System.String))
 
        'Configuration for CollCode Field
        drCustom = dtCustom.NewRow
        drCustom("FieldName") = "strCollCode"
        drCustom("dbFieldName") = "CollCode"
        drCustom("dbFieldType") = "System.Int16"
        drCustom("dbFieldMax") = 999
        drCustom("dbAllowNulls") = False
        drCustom("InputType") = "textbox"
        drCustom("InputLabel") = "Collateral Code:"
        drCustom("ValidateQuery") = ""
        drCustom("Query") = ""
        dtCustom.Rows.Add(drCustom)
 
        'Configuration for CollCode Description
        drCustom = dtCustom.NewRow
        drCustom("FieldName") = "strDescription"
        drCustom("dbFieldName") = "Description"
        drCustom("dbFieldType") = "System.String"
        drCustom("dbFieldMax") = 50
        drCustom("dbAllowNulls") = False
        drCustom("InputType") = "textbox"
        drCustom("InputLabel") = "Description: "
        drCustom("ValidateQuery") = ""
        drCustom("Query") = ""
        dtCustom.Rows.Add(drCustom)
 
        createForm(dtCustom)
    End Sub
 
-----Original Message-----
From: Shannon Horn [mailto:shannon_horn@w...] 
Sent: Friday, July 19, 2002 2:17 PM
To: ASPX_Professional
Subject: [aspx_professional] RE: Dynamic Web Form Events
 
Yes. If you have a specific question about it, we can probably help you out.
My initial introduction to the page life cycle and dynamic controls was even
more complex than usual because I was using it combined with SQL-DMO to add,
update, and delete actual stored procedure code in SQL Server.
 
-----Original Message-----
From: Thomas Fuller [mailto:TFuller@g...] 
Sent: Friday, July 19, 2002 11:07
To: ASPX_Professional
Subject: [aspx_professional] RE: Dynamic Web Form Events
 
Thank you very much.  I can't believe you have to use the page load or init
when you add event handlers.  That's going to kind of defeat the purpose of
dynamically creating the forms.  I guess I could use querystrings or some
other type of method for firing off adds/updates/deletes from this UI.
Have you done anything like this where you create a single page that will
View/Add/Update/Delete database records? 
Thanks Again, 
Tom 
-----Original Message----- 
From: Shannon Horn [mailto:shannon_horn@w...
<mailto:shannon_horn@w...> ] 
Sent: Friday, July 19, 2002 12:49 PM 
To: ASPX_Professional 
Cc: 'Brandon Searles' 
Subject: [aspx_professional] RE: Dynamic Web Form Events 
You have to add the event handlers in either the page init or the page 
load methods. This is sort of a pain if you are conditionally adding 
controls to a form since you cannot evaluate a condition until after the 
page init or page load has fired, however, you must add the event 
handlers in the page init or page load. Be sure to review the page life 
cycle for more information: 
Q317794 HOW TO: Dynamically Create Controls in ASP.NET w/Visual C# .NET 
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q317794
<http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q317794>  
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide>  
/html/cpconcontrolexecutionlifecycle.asp 
 Q305141 INFO: ASP.NET Page Framework Overview 
http://support.microsoft.com/support/kb/articles/q305/1/41.asp
<http://support.microsoft.com/support/kb/articles/q305/1/41.asp>  
 
-----Original Message----- 
From: Thomas Fuller [mailto:tfuller@g... <mailto:tfuller@g...> ]

Sent: Friday, July 19, 2002 17:37 
To: ASPX_Professional 
Subject: [aspx_professional] Dynamic Web Form Events 
Can anyone tell me how you can add event handlers to web controls at 
runtime.  I'm having no problem adding all kinds of dynamic elements 
using 
place holders but I can't get the form submit to actually fire off a 
click 
event or some type of on submit event.  Any help would be greatly 
appreciated. 
Thanks, 
Tom 
--- 
Change your mail options at http://p2p.wrox.com/manager.asp
<http://p2p.wrox.com/manager.asp>  or 
 
--- 
Change your mail options at http://p2p.wrox.com/manager.asp
<http://p2p.wrox.com/manager.asp>  or 
--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to  
--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to


  Return to Index