dprasad
asked on
Control 'btn' of type 'Button' must be placed inside a form tag with runat=server.
I should be to make a selection from a group of radio buttons or a dropdownlist, make a submission that stores it as a session variable and writes it to the screen. All I get is the submit button and no choices?
I get the <form runat=server> tag underlined by VS, it says 'per the active schema, the element form must be included in a parent element'
<%@ Page Language="vb" strict="true"%>
<script runat=server>
sub btn_click(ByVal Sender as Object, ByVal e as EventArgs)
if (rbl.SelectedIndex = -1) then
lblMsg.Text = "you must select a book category."
else
dim sb as stringBuilder = new StringBuilder( )
sb.Append("you have selected")
sb.Append(Cstr(Session("ca ttext")))
sb.Append(" with code ")
sb.Append(Cstr(Session("ca tcode")))
sb.Append(""".")
lblMsg.Text = sb.ToString( )
ddl.Visible = true
dim CatBooks() as string = CType(Session("books"), string())
'populate the dropdown list
dim i as integer
ddl.Items.Clear()
for i = 0 to CatBooks.GetLength(0) - 1
ddl.Items.Add(new ListItem(CatBooks(i)))
next
end if
end sub
sub rbl_SelectedIndexChanged(B yVal Sender as Object, ByVal e as EventArgs)
if (rbl.SelectedIndex <> -1) then
dim Books(3) as string
Session("cattext") = rbl.SelectedItem.Text
Session("catcode") = rbl.SelectedItem.Value
select case (rbl.SelectedItem.Value)
case "n"
Books(0) = "Programming c#"
Books(1) = "asp.net"
Books(2) = "c3 essentials"
case "d"
Books(0) = "oracle and open"
Books(1) = "sql"
Books(2) = "twsl"
case "h":
Books(0) = "pc hardware in a nutshell"
Books(1) = "dictionary of PC"
Books(2) = "linux"
end select
Session("books") = Books
end if
end sub
</script>
<form runat=server>
<asp:radioButtonList id="rbl" autopostback="false" cellspacing="20" repeatcolumns="3" repeatDirection="horizonta l" repeatlayout="table" textalign="right" onSelectedIndexChanged="rb l_Selected IndexChang ed" runat="server"></asp:radio ButtonList >
<asp:button id="btn" text="submit" onClick="btn_Click" runat="server"/>
<asp:label id="lblMsg" runat="server"/>
<asp:DropDownList id="ddl" autoPostBack="false" visible="false" runat="server"/>
</body>
</form>
</html>
I get the <form runat=server> tag underlined by VS, it says 'per the active schema, the element form must be included in a parent element'
<%@ Page Language="vb" strict="true"%>
<script runat=server>
sub btn_click(ByVal Sender as Object, ByVal e as EventArgs)
if (rbl.SelectedIndex = -1) then
lblMsg.Text = "you must select a book category."
else
dim sb as stringBuilder = new StringBuilder( )
sb.Append("you have selected")
sb.Append(Cstr(Session("ca
sb.Append(" with code ")
sb.Append(Cstr(Session("ca
sb.Append(""".")
lblMsg.Text = sb.ToString( )
ddl.Visible = true
dim CatBooks() as string = CType(Session("books"), string())
'populate the dropdown list
dim i as integer
ddl.Items.Clear()
for i = 0 to CatBooks.GetLength(0) - 1
ddl.Items.Add(new ListItem(CatBooks(i)))
next
end if
end sub
sub rbl_SelectedIndexChanged(B
if (rbl.SelectedIndex <> -1) then
dim Books(3) as string
Session("cattext") = rbl.SelectedItem.Text
Session("catcode") = rbl.SelectedItem.Value
select case (rbl.SelectedItem.Value)
case "n"
Books(0) = "Programming c#"
Books(1) = "asp.net"
Books(2) = "c3 essentials"
case "d"
Books(0) = "oracle and open"
Books(1) = "sql"
Books(2) = "twsl"
case "h":
Books(0) = "pc hardware in a nutshell"
Books(1) = "dictionary of PC"
Books(2) = "linux"
end select
Session("books") = Books
end if
end sub
</script>
<form runat=server>
<asp:radioButtonList id="rbl" autopostback="false" cellspacing="20" repeatcolumns="3" repeatDirection="horizonta
<asp:button id="btn" text="submit" onClick="btn_Click" runat="server"/>
<asp:label id="lblMsg" runat="server"/>
<asp:DropDownList id="ddl" autoPostBack="false" visible="false" runat="server"/>
</body>
</form>
</html>
I think you missed an <html> before <form>
ASKER
ok so i have
</script>
<html>
<form runat=server>
...
VS gives me a tooltip notice over <from runat:
'<form>' cant be nested within 'html'
I still only see a submit button
</script>
<html>
<form runat=server>
...
VS gives me a tooltip notice over <from runat:
'<form>' cant be nested within 'html'
I still only see a submit button
<html>
<body>
<form runat=server ID="Form1">
<asp:radioButtonList id="rbl" autopostback="false" cellspacing="20" repeatcolumns="3" repeatDirection="horizonta l" repeatlayout="table" textalign="right" onSelectedIndexChanged="rb l_Selected IndexChang ed" runat="server"></asp:radio ButtonList >
<asp:button id="btn" text="submit" onClick="btn_Click" runat="server"/>
<asp:label id="lblMsg" runat="server"/>
<asp:DropDownList id="ddl" autoPostBack="false" visible="false" runat="server"/>
</form>
</body>
</html>
<body>
<form runat=server ID="Form1">
<asp:radioButtonList id="rbl" autopostback="false" cellspacing="20" repeatcolumns="3" repeatDirection="horizonta
<asp:button id="btn" text="submit" onClick="btn_Click" runat="server"/>
<asp:label id="lblMsg" runat="server"/>
<asp:DropDownList id="ddl" autoPostBack="false" visible="false" runat="server"/>
</form>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.