Results 1 to 5 of 5

Thread: Checkbox runat="server"

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Posts
    19

    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

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    have you tried something like
    Code:
    Page.Controls.Add(chk)
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Posts
    19
    I tried. Server Error occured "A control cannot modify its parents' control collections.

  4. #4
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    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.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Posts
    19
    Yes, ur right the checkbox was created inside the datagrid on the user control

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width