-
Checkbox runat="server"
I have an ascx control has of DataGrid. My problem is that when I use the render control on the other page it has the error as follows: Checkbox must be placed inside a form tag with runat="server"
The checkbox was created dynamically in VB not in the HTML side. I suspected that this was the cause of the problem. How can I set the checkbox to has attribites <runat="server">?
I have tried the ff code but still it doesn't work:
Dim chk As CheckBox
Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
chk = New CheckBox()
htmlWrite.Write("<script>runat=server</script>")
chk.Attributes.AddAttributes(htmlWrite)
thanx
-
have you tried something like
Code:
Page.Controls.Add(chk)
-
I tried. Server Error occured "A control cannot modify its parents' control collections.
-
If you're creating your checkbox in the VB code-behind, it is running at the server.
You need to clarify to us where the checkbox is being created. I think you mean its being created inside the datagrid, in which case, the datagrid handles that all for you. You just need to find it on postback by referencing the datalistitem, and using the FindControl method.
-
Yes, ur right the checkbox was created inside the datagrid on the user control