asp.net ajax程序设计之笔记4--使用DragOverlayExtender拖动元素,结合ProfileService将位置信息保存至数据库

ProfileService.aspx 


<%@ Register Assembly="Microsoft.Web.Preview" Namespace="Microsoft.Web.Preview.UI.Controls"
    TagPrefix="asp" %><!--要把Microsoft.Web.Preview.dll引用到bin目录下-->

<form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
       
        <asp:ProfileService ID="ProfileService1" runat="server" AutoSave="true">
        </asp:ProfileService>

        <asp:DragOverlayExtender ID="DragOverlayExtender1" runat="server" Enabled="True" TargetControlID="Calendar1"  ProfileServiceID="ProfileService1" ProfileProperty="calendarPosition" />

        <asp:DragOverlayExtender ID="DragOverlayExtender2" runat="server" Enabled="true"
         TargetControlID="Login1" ProfileProperty="loginPosition" ProfileServiceID="ProfileService1" />

        <asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="#3366CC"
            BorderWidth="1px" CellPadding="1" DayNameFormat="Shortest" Font-Names="Verdana"
            Font-Size="8pt" ForeColor="#003399" Height="200px" Width="220px">
            <SelectedDayStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
            <TodayDayStyle BackColor="#99CCCC" ForeColor="White" />
            <SelectorStyle BackColor="#99CCCC" ForeColor="#336666" />
            <WeekendDayStyle BackColor="#CCCCFF" />
            <OtherMonthDayStyle ForeColor="#999999" />
            <NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF" />
            <DayHeaderStyle BackColor="#99CCCC" ForeColor="#336666" Height="1px" />
            <TitleStyle BackColor="#003399" BorderColor="#3366CC" BorderWidth="1px" Font-Bold="True"
                Font-Size="10pt" ForeColor="#CCCCFF" Height="25px" />
        </asp:Calendar>

        <asp:Login ID="Login1" runat="server" BackColor="#EFF3FB" BorderColor="#B5C7DE" BorderPadding="4" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#333333">
            <TitleTextStyle BackColor="#507CD1" Font-Bold="True" Font-Size="0.9em" ForeColor="White" />
            <InstructionTextStyle Font-Italic="True" ForeColor="Black" />
            <TextBoxStyle Font-Size="0.8em" />
            <LoginButtonStyle BackColor="White" BorderColor="#507CD1" BorderStyle="Solid" BorderWidth="1px"
                Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284E98" />
        </asp:Login>        
    </div>
    </form>

Web.config

  <connectionStrings>
    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer" connectionString="server=.;database=asp_net;uid=sa;pwd=sa" providerName="System.Data.SqlClient"/>
  </connectionStrings><!--启用ProfileService会使用aspnet_Profile表保存位置信息-->

<system.web>
<!--其它配置信息-->
<profile enabled="true">
   <properties><!--添加属性,分别用来保存日历和登录控件的位置-->
    <add name="calendarPosition" allowAnonymous="true" type="String"/>
    <add name="loginPosition" allowAnonymous="true" type="String"/>
   </properties>
  </profile><!--启用对匿名用户保存个性化信息的支持-->
  <anonymousIdentification enabled="true"/>
 </system.web>

<system.web.extensions>
  <scripting>
   <webServices>
        <!--设置读写属性 -->
    <profileService enabled="true" readAccessProperties="calendarPosition,loginPosition" writeAccessProperties="calendarPosition,loginPosition"/>
   </webServices>
 </scripting>
 </system.web.extensions>

运行页面,拖动并刷新页面,Calendar和Login会保留上次的位置,分别在IE和firefox中测试,可以跨浏览器
查看aspnet_profile表会查到以下类似记录:

UserId                                                                                                     PropertyNames                   PropertyValuesString
894E65AD-E188-46F6-87D2-0BBFD0B25332      loginPosition:S:0:5:calendarPosition:S:5:6:       85,21337,96 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值