954,595 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ajax and dynamic control created at run time

can u correct the error

Parser Error Message: Type 'System.Web.UI.UpdatePanel' does not have a public property named 'table'.

i have following code

Public Partial Class WebForm1
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub
    Protected Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
        If RadioButtonList1.SelectedValue = "blue" Then
            TextBox1.BackColor = System.Drawing.Color.Blue
            TextBox1.ForeColor = System.Drawing.Color.White
        ElseIf RadioButtonList1.SelectedValue = "red" Then
            TextBox1.BackColor = System.Drawing.Color.Red
            TextBox1.ForeColor = System.Drawing.Color.Black
        ElseIf RadioButtonList1.SelectedValue = "white" Then
            TextBox1.BackColor = System.Drawing.Color.White
            TextBox1.ForeColor = System.Drawing.Color.Black
        End If
    End Sub

    Protected Sub RadioButtonList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButtonList2.SelectedIndexChanged
        Response.Write(RadioButtonList2.SelectedValue)
        Dim index As Integer

        For index = 1 To Me.RadioButtonList2.SelectedValue
            Dim newdiv As New HtmlGenericControl("div")
            newdiv.EnableViewState = True
            Dim ht As New HtmlTable()
            ht.ID = "mytable" & index
            ht.EnableViewState = True

            ht.Width = "100%"
            ht.CellSpacing = "0"
            ht.CellPadding = "0"
            ht.Border = 0


            Dim htr, htr1, htr2 As New HtmlTableRow()
            Dim cell, htc, htc1, htc2, htc3, htc4, htc5, htc6, htc7, htc8 As New HtmlTableCell()

            Dim name_tb As New TextBox()
            Dim sal_ddl As New DropDownList

            'validator
            Dim name_req As New RequiredFieldValidator
            Dim tel_req As New RequiredFieldValidator
            Dim email_req As New RequiredFieldValidator


            name_tb.ID = "name_tb" & index
            sal_ddl.ID = "sal_ddl" & index
            name_req.ID = "name_req" & index
            tel_req.ID = "tel_req" & index
            email_req.ID = "email_req" & index
            name_tb.EnableViewState = True
            sal_ddl.EnableViewState = True
            tel_req.EnableViewState = True

            sal_ddl.Items.Add("MR")
            sal_ddl.Items.Add("Ms")
            sal_ddl.Items.Add("Mrs")



            Dim Tel_tb1 As New TextBox
            Tel_tb1.ID = "Tel_tb1" & index
            Tel_tb1.EnableViewState = True
            name_tb.TextMode = TextBoxMode.SingleLine

            Dim email_tb1 As New TextBox
            email_tb1.ID = "email_tb1" & index
            email_tb1.TextMode = TextBoxMode.SingleLine

            htc.InnerText = "Name : "
            htc.Width = "20%"
            htc.Align = "Left"



            htc1.Controls.Add(sal_ddl)
            htc1.Width = "10%"

            htc2.Width = "70%"
            htc2.Align = "left"



            htc2.Controls.Add(name_tb)
            htc2.Controls.Add(name_req)
            htr.Controls.Add(htc)
            htr.Controls.Add(htc1)
            htr.Controls.Add(htc2)


            ht.Controls.Add(htr)
            name_req.ControlToValidate = "name_tb" & index
            name_req.Display = ValidatorDisplay.Dynamic
            name_req.ErrorMessage = ("Please Enter name of attendenes")


            'make 2nd  row 

            htc3.InnerText = "Telephone : "
            htc3.Width = "20%"
            htc3.Align = "Left"


            htc4.InnerHtml = "<strong></strong>"
            htc4.Width = "10%"

            htc5.Width = "70%"
            htc5.Align = "left"

            htc5.Controls.Add(Tel_tb1)
            htc5.Controls.Add(tel_req)
            htr1.Controls.Add(htc3)
            htr1.Controls.Add(htc4)
            htr1.Controls.Add(htc5)


            ht.Controls.Add(htr1)

            tel_req.ControlToValidate = "Tel_tb1" & index
            tel_req.Display = ValidatorDisplay.Dynamic
            tel_req.ErrorMessage = ("Please Enter Phone")


            'make 3rd  row 

            htc6.InnerText = "Email : "
            htc6.Width = "20%"
            htc6.Align = "Left"


            htc7.InnerHtml = "<strong></strong>"
            htc7.Width = "10%"

            htc8.Width = "70%"
            htc8.Align = "left"

            htc8.Controls.Add(email_tb1)
            htc8.Controls.Add(email_req)
            htr2.Controls.Add(htc6)
            htr2.Controls.Add(htc7)
            htr2.Controls.Add(htc8)

            ht.Controls.Add(htr2)

            email_req.ControlToValidate = "email_tb1" & index
            email_req.Display = ValidatorDisplay.Dynamic
            email_req.ErrorMessage = ("Please Enter Email")

            'Add  a blank row

            cell.ColSpan = 3
            cell.InnerHtml = "<br/>"
            Dim row As New HtmlTableRow
            row.Cells.Add(cell)
            ht.Rows.Add(row)

            newdiv.Controls.Add(ht)

            newdiv.Attributes.Add("table", "ht")



            newdiv.Attributes.Add("Style", "border-bottom :#ccc solid 0px")
            newdiv.Attributes.Add("style", "height:23px")
            newdiv.Attributes.Add("style", "padding-left:20px")



            Me.PlaceHolder1.Controls.Add(newdiv)
            PlaceHolder1.EnableViewState = True

        Next



    End Sub
End Class
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="gfln1.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
     <link href="css/styles.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" runat=server>
    
            </script>
</head>
<body>
    <form id="form1" runat="server"> 
<asp:ScriptManager ID="ScriptManager1" runat="server" />

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
<Triggers> 
<asp:AsyncPostBackTrigger ControlID="RadioButtonList1" EventName="SelectedIndexChanged" />
</Triggers>

<ContentTemplate> 
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"> 
<asp:ListItem Text="Blue" Value="blue"></asp:ListItem>
<asp:ListItem Text="Red" Value="red"></asp:ListItem>
<asp:ListItem Text="White" Value="white"></asp:ListItem>
</asp:RadioButtonList>

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>

<div class="right_txt_space_accm">
<asp:UpdatePanel ID="UpdatePanel2" runat="server"> 
<Triggers>
<asp:AsyncPostBackTrigger ControlID="RadioButtonList2" EventName="SelectedIndexChanged" />
</Triggers>

											<table width="100%" border="0" cellspacing="0" cellpadding="0">
											  <tr>
												<td width="40%" align="left"><strong>Number of 
                                                attendees:</strong></td>
												<td width="60%" align="left"><strong>
												
												<ContentTemplate>
                                               <asp:RadioButtonList EnableViewState=true  ID="RadioButtonList2" CellSpacing=13  RepeatDirection=Horizontal  runat="server" RepeatColumns=4 AutoPostBack="true">
                                                        <asp:ListItem>1</asp:ListItem>
                                                        <asp:ListItem>2</asp:ListItem>
                                                        <asp:ListItem>3</asp:ListItem>
                                                        <asp:ListItem>4</asp:ListItem>
                                                        <asp:ListItem>5</asp:ListItem>
                                                        <asp:ListItem>6</asp:ListItem>
                                                        <asp:ListItem>7</asp:ListItem>
                                                        
                                                    </asp:RadioButtonList>   </strong></td>
                                                    </ContentTemplate>
                                </asp:UpdatePanel>

												
											  </tr>
											</table>
										</div>
    <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
    
</form>
</body>
</html>
erum
Junior Poster in Training
72 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0
 
Protected Sub RadioButtonList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButtonList2.SelectedIndexChanged
        'Response.Write(RadioButtonList2.SelectedValue)
        Dim index As Integer

        For index = 1 To Me.RadioButtonList2.SelectedValue
            Dim newdiv As New HtmlGenericControl("div")
            newdiv.EnableViewState = True
            Dim ht As New HtmlTable()
            ht.BgColor = "cyan"
            ht.ID = "mytable" & index
            ht.EnableViewState = True

            ht.Width = "100%"
            ht.CellSpacing = "0"
            ht.CellPadding = "0"
            ht.Border = 0


            Dim htr, htr1, htr2 As New HtmlTableRow()
            Dim cell, htc, htc1, htc2, htc3, htc4, htc5, htc6, htc7, htc8 As New HtmlTableCell()

            Dim name_tb As New TextBox()
            Dim sal_ddl As New DropDownList

            'validator
            Dim name_req As New RequiredFieldValidator
            Dim tel_req As New RequiredFieldValidator
            Dim email_req As New RequiredFieldValidator


            name_tb.ID = "name_tb" & index
            sal_ddl.ID = "sal_ddl" & index
            name_req.ID = "name_req" & index
            tel_req.ID = "tel_req" & index
            email_req.ID = "email_req" & index
            name_tb.EnableViewState = True
            sal_ddl.EnableViewState = True
            tel_req.EnableViewState = True

            sal_ddl.Items.Add("MR")
            sal_ddl.Items.Add("Ms")
            sal_ddl.Items.Add("Mrs")



            Dim Tel_tb1 As New TextBox
            Tel_tb1.ID = "Tel_tb1" & index
            Tel_tb1.EnableViewState = True
            name_tb.TextMode = TextBoxMode.SingleLine

            Dim email_tb1 As New TextBox
            email_tb1.ID = "email_tb1" & index
            email_tb1.TextMode = TextBoxMode.SingleLine

            htc.InnerText = "Name : "
            htc.Width = "20%"
            htc.Align = "Left"



            htc1.Controls.Add(sal_ddl)
            htc1.Width = "10%"

            htc2.Width = "70%"
            htc2.Align = "left"



            htc2.Controls.Add(name_tb)
            htc2.Controls.Add(name_req)
            htr.Controls.Add(htc)
            htr.Controls.Add(htc1)
            htr.Controls.Add(htc2)


            ht.Controls.Add(htr)
            name_req.ControlToValidate = "name_tb" & index
            name_req.Display = ValidatorDisplay.Dynamic
            name_req.ErrorMessage = ("Please Enter name of attendenes")


            'make 2nd  row 

            htc3.InnerText = "Telephone : "
            htc3.Width = "20%"
            htc3.Align = "Left"


            htc4.InnerHtml = "<strong></strong>"
            htc4.Width = "10%"

            htc5.Width = "70%"
            htc5.Align = "left"

            htc5.Controls.Add(Tel_tb1)
            htc5.Controls.Add(tel_req)
            htr1.Controls.Add(htc3)
            htr1.Controls.Add(htc4)
            htr1.Controls.Add(htc5)


            ht.Controls.Add(htr1)

            tel_req.ControlToValidate = "Tel_tb1" & index
            tel_req.Display = ValidatorDisplay.Dynamic
            tel_req.ErrorMessage = ("Please Enter Phone")


            'make 3rd  row 

            htc6.InnerText = "Email : "
            htc6.Width = "20%"
            htc6.Align = "Left"


            htc7.InnerHtml = "<strong></strong>"
            htc7.Width = "10%"

            htc8.Width = "70%"
            htc8.Align = "left"

            htc8.Controls.Add(email_tb1)
            htc8.Controls.Add(email_req)
            htr2.Controls.Add(htc6)
            htr2.Controls.Add(htc7)
            htr2.Controls.Add(htc8)

            ht.Controls.Add(htr2)

            email_req.ControlToValidate = "email_tb1" & index
            email_req.Display = ValidatorDisplay.Dynamic
            email_req.ErrorMessage = ("Please Enter Email")

            'Add  a blank row

            cell.ColSpan = 3
            cell.InnerHtml = "<br/>"
            Dim row As New HtmlTableRow
            row.Cells.Add(cell)
            ht.Rows.Add(row)

            newdiv.Controls.Add(ht)

            newdiv.Attributes.Add("table", "ht")



            newdiv.Attributes.Add("Style", "border-bottom :#ccc solid 0px")
            newdiv.Attributes.Add("style", "height:23px")
            newdiv.Attributes.Add("style", "padding-left:20px")



            Me.PlaceHolder1.Controls.Add(newdiv)
            PlaceHolder1.EnableViewState = True

        Next


<pre><code>&lt;div class=&quot;right_txt_space_accm&quot;&gt;
&lt;asp:UpdatePanel ID=&quot;UpdatePanel2&quot; runat=&quot;server&quot; UpdateMode=Conditional&gt;
&lt;Triggers&gt;
&lt;asp:AsyncPostBackTrigger ControlID=&quot;RadioButtonList2&quot; EventName=&quot;SelectedIndexChanged&quot; /&gt;
&lt;/Triggers&gt;&lt;ContentTemplate&gt;
                                            &lt;table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;
                                              &lt;tr&gt;
                                                &lt;td width=&quot;40%&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Number of                                                attendees:&lt;/strong&gt;&lt;/td&gt;
                                                &lt;td width=&quot;60%&quot; align=&quot;left&quot;&gt;&lt;strong&gt;
                                               &lt;asp:RadioButtonList EnableViewState=true  ID=&quot;RadioButtonList2&quot; CellSpacing=13  RepeatDirection=Horizontal  runat=&quot;server&quot; RepeatColumns=4 AutoPostBack=&quot;true&quot;&gt;
                                                        &lt;asp:ListItem&gt;1&lt;/asp:ListItem&gt;
                                                        &lt;asp:ListItem&gt;2&lt;/asp:ListItem&gt;
                                                        &lt;asp:ListItem&gt;3&lt;/asp:ListItem&gt;
                                                        &lt;asp:ListItem&gt;4&lt;/asp:ListItem&gt;
                                                        &lt;asp:ListItem&gt;5&lt;/asp:ListItem&gt;
                                                        &lt;asp:ListItem&gt;6&lt;/asp:ListItem&gt;
                                                        &lt;asp:ListItem&gt;7&lt;/asp:ListItem&gt;
                                                    &lt;/asp:RadioButtonList&gt;   &lt;/strong&gt;&lt;/td&gt;
                                              &lt;/tr&gt;
                                            &lt;/table&gt;&lt;/ContentTemplate&gt;
                                &lt;/asp:UpdatePanel&gt;
                                        &lt;/div&gt; 
    &lt;asp:PlaceHolder ID=&quot;PlaceHolder1&quot; runat=&quot;server&quot;&gt;&lt;/asp:PlaceHolder&gt;</code></pre>









    End Sub
Protected Sub RadioButtonList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButtonList2.SelectedIndexChanged
        'Response.Write(RadioButtonList2.SelectedValue)
        Dim index As Integer

        For index = 1 To Me.RadioButtonList2.SelectedValue
            Dim newdiv As New HtmlGenericControl("div")
            newdiv.EnableViewState = True
            Dim ht As New HtmlTable()
            ht.BgColor = "cyan"
            ht.ID = "mytable" & index
            ht.EnableViewState = True

            ht.Width = "100%"
            ht.CellSpacing = "0"
            ht.CellPadding = "0"
            ht.Border = 0


            Dim htr, htr1, htr2 As New HtmlTableRow()
            Dim cell, htc, htc1, htc2, htc3, htc4, htc5, htc6, htc7, htc8 As New HtmlTableCell()

            Dim name_tb As New TextBox()
            Dim sal_ddl As New DropDownList

            'validator
            Dim name_req As New RequiredFieldValidator
            Dim tel_req As New RequiredFieldValidator
            Dim email_req As New RequiredFieldValidator


            name_tb.ID = "name_tb" & index
            sal_ddl.ID = "sal_ddl" & index
            name_req.ID = "name_req" & index
            tel_req.ID = "tel_req" & index
            email_req.ID = "email_req" & index
            name_tb.EnableViewState = True
            sal_ddl.EnableViewState = True
            tel_req.EnableViewState = True

            sal_ddl.Items.Add("MR")
            sal_ddl.Items.Add("Ms")
            sal_ddl.Items.Add("Mrs")



            Dim Tel_tb1 As New TextBox
            Tel_tb1.ID = "Tel_tb1" & index
            Tel_tb1.EnableViewState = True
            name_tb.TextMode = TextBoxMode.SingleLine

            Dim email_tb1 As New TextBox
            email_tb1.ID = "email_tb1" & index
            email_tb1.TextMode = TextBoxMode.SingleLine

            htc.InnerText = "Name : "
            htc.Width = "20%"
            htc.Align = "Left"



            htc1.Controls.Add(sal_ddl)
            htc1.Width = "10%"

            htc2.Width = "70%"
            htc2.Align = "left"



            htc2.Controls.Add(name_tb)
            htc2.Controls.Add(name_req)
            htr.Controls.Add(htc)
            htr.Controls.Add(htc1)
            htr.Controls.Add(htc2)


            ht.Controls.Add(htr)
            name_req.ControlToValidate = "name_tb" & index
            name_req.Display = ValidatorDisplay.Dynamic
            name_req.ErrorMessage = ("Please Enter name of attendenes")


            'make 2nd  row 

            htc3.InnerText = "Telephone : "
            htc3.Width = "20%"
            htc3.Align = "Left"


            htc4.InnerHtml = "<strong></strong>"
            htc4.Width = "10%"

            htc5.Width = "70%"
            htc5.Align = "left"

            htc5.Controls.Add(Tel_tb1)
            htc5.Controls.Add(tel_req)
            htr1.Controls.Add(htc3)
            htr1.Controls.Add(htc4)
            htr1.Controls.Add(htc5)


            ht.Controls.Add(htr1)

            tel_req.ControlToValidate = "Tel_tb1" & index
            tel_req.Display = ValidatorDisplay.Dynamic
            tel_req.ErrorMessage = ("Please Enter Phone")


            'make 3rd  row 

            htc6.InnerText = "Email : "
            htc6.Width = "20%"
            htc6.Align = "Left"


            htc7.InnerHtml = "<strong></strong>"
            htc7.Width = "10%"

            htc8.Width = "70%"
            htc8.Align = "left"

            htc8.Controls.Add(email_tb1)
            htc8.Controls.Add(email_req)
            htr2.Controls.Add(htc6)
            htr2.Controls.Add(htc7)
            htr2.Controls.Add(htc8)

            ht.Controls.Add(htr2)

            email_req.ControlToValidate = "email_tb1" & index
            email_req.Display = ValidatorDisplay.Dynamic
            email_req.ErrorMessage = ("Please Enter Email")

            'Add  a blank row

            cell.ColSpan = 3
            cell.InnerHtml = "<br/>"
            Dim row As New HtmlTableRow
            row.Cells.Add(cell)
            ht.Rows.Add(row)

            newdiv.Controls.Add(ht)

            newdiv.Attributes.Add("table", "ht")



            newdiv.Attributes.Add("Style", "border-bottom :#ccc solid 0px")
            newdiv.Attributes.Add("style", "height:23px")
            newdiv.Attributes.Add("style", "padding-left:20px")



            Me.PlaceHolder1.Controls.Add(newdiv)
            PlaceHolder1.EnableViewState = True

        Next



    End Sub


last problem i have solved ,but now i have above code ,it does not showing me any thing

erum
Junior Poster in Training
72 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0
 

i make certain changes in .aspx code

<div class="right_txt_space_accm">
 <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode=conditional>

<ContentTemplate>
                                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                              <tr>
                                                <td width="40%" align="left"><strong>Number of                                                attendees:</strong></td>
                                                <td width="60%" align="left"><strong>
                                               <asp:RadioButtonList EnableViewState=true  ID="RadioButtonList1" CellSpacing=13 OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged" RepeatDirection=Horizontal  runat="server" RepeatColumns=4 AutoPostBack="true">
                                                        <asp:ListItem>1</asp:ListItem>
                                                        <asp:ListItem>2</asp:ListItem>
                                                        <asp:ListItem>3</asp:ListItem>
                                                        <asp:ListItem>4</asp:ListItem>
                                                        <asp:ListItem>5</asp:ListItem>
                                                        <asp:ListItem>6</asp:ListItem>
                                                        <asp:ListItem>7</asp:ListItem>
                                                    </asp:RadioButtonList>   </strong></td>
                                              </tr>
                                            </table>
                                            		
     <asp:PlaceHolder  ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
                                        
                                            </ContentTemplate>
                                            <Triggers>
                                           <asp:AsyncPostBackTrigger ControlID="RadioButtonList1" EventName="SelectedIndexChanged" />
                                           </Triggers>
                                           
                                </asp:UpdatePanel>
                                        </div>
		   
               
          
          
          
          
			
				<div class="right_txt_space_accm">
				<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode=conditional>

<ContentTemplate>
 
											<table width="100%" border="0" cellspacing="0" cellpadding="0">
											  <tr>
												<td width="50%" align="left"><strong> Would attend the conference </strong></td>
													
												<td width="50%" align="left"><strong></strong>   
                                                    <asp:RadioButtonList EnableViewState=true  RepeatDirection=Horizontal  ID="spous_atend_Conference"  
                                                        runat="server" AutoPostBack="True">
                                                        <asp:ListItem Value="0">Yes</asp:ListItem>
                                                        <asp:ListItem Selected="True" Value="1">No</asp:ListItem>
                                                    </asp:RadioButtonList>
                                                   
                                                  </td>
											  </tr>
											</table>
											
											<asp:PlaceHolder ID=placeholder2 runat=server >
										</asp:PlaceHolder>
											</ContentTemplate>
                                            <Triggers>
                                            <asp:AsyncPostBackTrigger ControlID="spous_atend_Conference" EventName="SelectedIndexChanged" />

                                         
                                                                                 

                </Triggers>
                                            
                                </asp:UpdatePanel>
                        
										</div>


but ouput is bad on screen overlapp on rest of the UI .please see image last post that i posted on this thread http://www.vbforums.com/showthread.php?t=632101

here is an image i attached on vbforums .

erum
Junior Poster in Training
72 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: