C
Chad
I have a link (.ascx) and that generates an Add form on that page. The
autopostback dropdown is within a "If Not IsPostBack Then" statement.
The form that is created is all via static html in the user control.
The problem is, no matter what even when no data is filled out in the
form, the submit button just postsback the page and nothing happens. I
have 2 dummy links on the page right now, and the form is automatically
created without a link click for testing purposes. I thought that
onclick events work in a user control but maybe I'm wrong.
Oh, and stuff works in the .ascx, for instance response.write's appear
from the Page_Load, it's just this onclick event that won't work.
Here's the code:
Sub Page_Load(Sender As Object, E As EventArgs)
'Constants, link, local path, and sql connection.
strLink =
System.Configuration.ConfigurationSettings.AppSettings("LinkPath")
strPath =
System.Configuration.ConfigurationSettings.AppSettings("SitePath")
Conn = New
SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("SQLConnect"))
strBaseQuery = "Select TableName from TableGenData where Display = 4
Order By TableName Asc;"
If Not IsPostBack Then
conn.open()
'Populates the dropdown with the Status Names.
cmdSelect = New SqlCommand(strBaseQuery, Conn)
dtrTableData = cmdSelect.ExecuteReader()
TableDropDown.DataSource = dtrTableData
TableDropDown.DataTextField = "TableName"
TableDropDown.DataValueField = "TableName"
TableDropDown.DataBind()
dtrTableData.Close
conn.close()
Dim li As ListItem
li = New ListItem("Select a Table", "0")
TableDropDown.Items.Insert(0, li)
End If
'The control is added here.
ctlControl = LoadControl( "AddDB.ascx" )
plhContent.Controls.Add( ctlControl )
'<ManageDB:AddDB ID="ctlAddDB" Runat="Server" />
End Sub
***********************
Here is the control:
'On button submit, grab the data from each form and submit it to SQL.
Sub SubmitForm_Click(s As Object, e as EventArgs)
Response.write( "omg it worked" )
End Sub
Now, of course there is a form below that has all the .text fields but
I'm hoping you can imagine those being there. The .ascx also contains
the <asp:Button OnClick=SubmitForm_Click runat=server /> as well. If
anything, I tried getting it to just error on me and nothing would
happen. I'm not sure if you would need more info, but if so I have
absolutely no problem providing it.
I looked around groups, and around forums for about an hour but I
couldn't find an answer. Maybe I'm just looking in the wrong places,
with the wrong search terms.
Thanks for the help in advance!
autopostback dropdown is within a "If Not IsPostBack Then" statement.
The form that is created is all via static html in the user control.
The problem is, no matter what even when no data is filled out in the
form, the submit button just postsback the page and nothing happens. I
have 2 dummy links on the page right now, and the form is automatically
created without a link click for testing purposes. I thought that
onclick events work in a user control but maybe I'm wrong.
Oh, and stuff works in the .ascx, for instance response.write's appear
from the Page_Load, it's just this onclick event that won't work.
Here's the code:
Sub Page_Load(Sender As Object, E As EventArgs)
'Constants, link, local path, and sql connection.
strLink =
System.Configuration.ConfigurationSettings.AppSettings("LinkPath")
strPath =
System.Configuration.ConfigurationSettings.AppSettings("SitePath")
Conn = New
SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("SQLConnect"))
strBaseQuery = "Select TableName from TableGenData where Display = 4
Order By TableName Asc;"
If Not IsPostBack Then
conn.open()
'Populates the dropdown with the Status Names.
cmdSelect = New SqlCommand(strBaseQuery, Conn)
dtrTableData = cmdSelect.ExecuteReader()
TableDropDown.DataSource = dtrTableData
TableDropDown.DataTextField = "TableName"
TableDropDown.DataValueField = "TableName"
TableDropDown.DataBind()
dtrTableData.Close
conn.close()
Dim li As ListItem
li = New ListItem("Select a Table", "0")
TableDropDown.Items.Insert(0, li)
End If
'The control is added here.
ctlControl = LoadControl( "AddDB.ascx" )
plhContent.Controls.Add( ctlControl )
'<ManageDB:AddDB ID="ctlAddDB" Runat="Server" />
End Sub
***********************
Here is the control:
'On button submit, grab the data from each form and submit it to SQL.
Sub SubmitForm_Click(s As Object, e as EventArgs)
Response.write( "omg it worked" )
End Sub
Now, of course there is a form below that has all the .text fields but
I'm hoping you can imagine those being there. The .ascx also contains
the <asp:Button OnClick=SubmitForm_Click runat=server /> as well. If
anything, I tried getting it to just error on me and nothing would
happen. I'm not sure if you would need more info, but if so I have
absolutely no problem providing it.
I looked around groups, and around forums for about an hour but I
couldn't find an answer. Maybe I'm just looking in the wrong places,
with the wrong search terms.
Thanks for the help in advance!