包子大寨

导航

【asp.net】web控件总结

AdRotator:

XML中出现的属性:

 

 

<Advertisements  xmlns="http://schemas.microsoft.com/AspNet/AdRotator-Advertisement-File-1.2">

 <Ad>

    <ImageUrl>图片地址</ImageUrl>

    <NavigateUrl>转向的地址</NavigateUrl>

    <AlternateText>图片不能显示时的文本</AlternateText>

    <Keyword>广告类别</Keyword>

    <Impressions>显示频率</Impressions>

    <Height>广告的高</Height>

    <Width>广告的宽</Width>

  </Ad>

</Advertisements>

 

注意:必须按照以上格式书写xml文件,因为他利用的namespace中这么要求的。

 

在asp.net中使用xml

<asp:AdRotator ID="Myadr" runat="server"  AdvertisementFile="ads.xml"  />

 

或则

 <asp:AdRotator ID="Myadr" runat="server" DataSourceID="xmlAd" />

 <asp:XmlDataSource ID="xmlAd" runat="server" DataFile="~/AdRotator/ads.xml"> </asp:XmlDataSource>
 

Button、LinkButtion、ImageButton:

使用方法:

Button

<asp:LinkButton  ID=""  runat="server"  OnClick=" "> Linkbutton   </asp:LinkButton>

LinkButton 

<asp:LinkButton  ID=""  runat="server"  OnClick=" "> Linkbutton   </asp:LinkButton>

ImageButton

<asp:ImageButton  ID=""  runat="server"  ImageUrl="~ "  OnClick=" " />

 

Calendar:

 <asp:Calendar ID="" runat="server" OnDayRender="Calendar1_DayRender" Height="206px" Width="369px"> </asp:Calendar>

Panel:

 <asp:Panel ID="pan1" runat="server"  Visible="true">

Substitution:

<asp:Substitution  ID="users"  MethodName="GetUser"  runat="server" />

注意:这个控件MethodName中定义的方法有如下要求

① 静态方法

② 方法接受HttpContext类型的参数

③ 方法返回String类型的值

例如:

 public static string GetUser(HttpContext context)

 {

        return context.User.Identity.Name;

 }

注意:这里的原理与AJAX有些关系。等深入学习后再回来思考

Wizard:

<asp:Wizard ID="Wizard2" runat="server">

     <WizardSteps>

          <asp:WizardStep runat="server" Title="Step 1" StepType="Start">

            添加内容

          </asp:WizardStep>

          <asp:WizardStep runat="server" Title="Step 2" StepType="Auto">

            添加内容

          </asp:WizardStep>

          </WizardSteps>

</asp:Wizard>

1、设置StepType时,有Start、Step、Finish,Complete以及Auto五项选择。表示该步骤的属性,

2、将步骤转化为***NaviTemplate后,进行对该步骤页面进行编辑,包括页面内下一步,上一步,完成,取消等事件的响应。

3、DisplaySideBar表示对于边栏的显示。

 

CheckBox:

 <asp:CheckBox ID="CheckBox2" runat="server"  AutoPostBack="True"  Text="example" />

AutoPostBack属性,表示单击控件时,是否自动发回服务器。

常用属性:CheckBox2.checked(返回true or false)

常用事件:OnCheckedChanged="CB_CheckedChanged"

          OnLoad="CB_CheckedLoad"

CheckBoxList:

<asp:CheckBoxList  ID="cbl"  runat="server"  AutoPostBack="True"  OnSelectedIndexChanged=" ">

     <asp:ListItem>呵呵</asp:ListItem>

     <asp:ListItem>嘿嘿</asp:ListItem>

     <asp:ListItem>哈哈</asp:ListItem>

</asp:CheckBoxList>

cbl.Items[0].selected(返回 true or  false)

cbl.Items[1].Text=?(返回值)

都是利用Items这个属性来调用的;

 

RadioButton:

 <asp:RadioButton ID="RBtn1" runat="server" Text="1号选项" GroupName="g1" />

如果不写GroupName属性的,该控件每项可以选择一次,且不可以取消。

反之,成为单选控件。

 

RadioButtonList:

<asp:RadioButtonList  ID="RBtn"  runat="server">

    <asp:ListItem> 1 </asp:ListItem>

    <asp:ListItem> 2 </asp:ListItem>

    <asp:ListItem> 3 </asp:ListItem>

</asp:RadioButtonList>

 

Items[]来获取属性

与很CheckBoxList很类似,但是这个仅是用于单选,而CheckBoxList可以用于多选

posted on 2010-02-19 11:36  疯狂的包子  阅读(349)  评论(0编辑  收藏  举报