ASP.Net/Asp Control/Panel — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 15:30, 26 мая 2010
Содержание
Basic Panel Control: holding other controls (VB.net)
<%@ Page Language=VB Debug=true %>
<HTML>
<HEAD>
<TITLE>Creating a Basic Panel Control</TITLE>
</HEAD>
<BODY LEFTMARGIN="40">
<form runat="server">
<asp:panel
id="Panel1"
runat="server"
height="80%"
width="90%">
Enter your name:<BR>
<asp:textbox
id="txtName"
runat=server
/>
<BR>
Enter your password:<BR>
<asp:textbox
id="txtPassword"
runat=server
/>
<BR>
</asp:Panel>
</form>
</BODY>
</HTML>
Hide and show asp:Panel in order to hide and show the controls it contains
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs)
If rdlOther.Checked Then
pnlOther.Visible = True
Else
pnlOther.Visible = False
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Show Panel</title>
</head>
<body>
<form id="form1" runat="server">
Select your programming language:
<asp:RadioButton
id="rdlVisualBasic"
GroupName="language"
Text="Visual Basic"
Runat="server" />
<asp:RadioButton
id="rdlCSharp"
GroupName="language"
Text="C#"
Runat="server" />
<asp:RadioButton
id="rdlOther"
GroupName="language"
Text="Other Language"
Runat="server" />
<asp:Panel
id="pnlOther"
Visible="false"
Runat="server">
<asp:Label
id="lblOther"
Text="Other Language:"
AssociatedControlID="txtOther"
Runat="server" />
<asp:TextBox
id="txtOther"
Runat="server" />
</asp:Panel>
<asp:Button
id="btnSubmit"
Text="Submit"
OnClick="btnSubmit_Click"
Runat="server" />
</form>
</body>
</html>
Make the asp panel visible (C#)
<%@ Page Language="C#" %>
<script runat="server">
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (rdlOther.Checked)
pnlOther.Visible = true;
else
pnlOther.Visible = false;
}
</script>
<html>
<head>
<title>Show Panel</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Select your favorite programming language:
<br /><br />
<asp:RadioButton
id="rdlVisualBasic"
GroupName="language"
Text="Visual Basic"
Runat="server" />
<br /><br />
<asp:RadioButton
id="rdlCSharp"
GroupName="language"
Text="C#"
Runat="server" />
<br /><br />
<asp:RadioButton
id="rdlOther"
GroupName="language"
Text="Other Language"
Runat="server" />
<br />
<asp:Panel
id="pnlOther"
Visible="false"
Runat="server">
<asp:Label
id="lblOther"
Text="Other Language:"
AssociatedControlID="txtOther"
Runat="server" />
<asp:TextBox
id="txtOther"
Runat="server" />
</asp:Panel>
<br /><br />
<asp:Button
id="btnSubmit"
Text="Submit"
Runat="server" OnClick="btnSubmit_Click" />
</div>
</form>
</body>
</html>
Panel Control: border style (VB.net)
<%@ Page Language=VB Debug=true %>
<HTML>
<HEAD>
<TITLE>Setting the Style of a Panel Control</TITLE>
</HEAD>
<BODY LEFTMARGIN="40">
<form runat="server">
<asp:panel
id="Panel1"
runat="server"
font-name="Arial"
font-bold="True"
forecolor="yellow"
backcolor="blue"
borderstyle=3
bordercolor="green"
borderwidth=4
horizontalalign="Center"
>
Enter your name:<BR>
<asp:textbox
id="txtName"
runat=server
/>
<BR>
Enter your password:<BR>
<asp:textbox
id="txtPassword"
runat=server
/>
</asp:Panel>
</form>
</BODY>
</HTML>
Panel Control: foreground and background color (VB.net)
<%@ Page Language=VB Debug=true %>
<HTML>
<HEAD>
<TITLE>Setting the Style of a Panel Control</TITLE>
</HEAD>
<BODY LEFTMARGIN="40">
<form runat="server">
<asp:panel
id="Panel1"
runat="server"
font-name="Arial"
font-bold="True"
forecolor="yellow"
backcolor="blue"
borderstyle=3
bordercolor="green"
borderwidth=4
horizontalalign="Center"
>
Enter your name:<BR>
<asp:textbox
id="txtName"
runat=server
/>
<BR>
Enter your password:<BR>
<asp:textbox
id="txtPassword"
runat=server
/>
</asp:Panel>
</form>
</BODY>
</HTML>
Scrollable asp panel (C#)
<%@ Page Language="C#" %>
<script runat="server">
void Page_Load()
{
for (int i = 0; i < 100; i++)
bltList.Items.Add("Item " + i.ToString());
}
</script>
<html>
<head>
<style type="text/css">
html
{
background-color:silver;
}
.contents
{
background-color:white;
width:200px;
height:200px;
}
</style>
<title>Panel ScrollBars</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Panel
id="pnlContent"
ScrollBars="Auto"
CssClass="contents"
Runat="server">
<asp:BulletedList
id="bltList"
Runat="server" />
</asp:Panel>
</div>
</form>
</body>
</html>