--我先介绍下这个咚咚有点像CommunityServer首页上修改新闻的功能哈哈
- -我看了CommunityServer口水流啊流终于有此修改^^绝对是自己搞得


单击

弹出

修改完毕
简单的逻辑过程-结合下面的aspx说说页面上的简单逻辑哈哈:
当你单击名称为-Title的div时-ModalPopupExtender就弹出让你修改标题,当你点关闭的时候(首先当然ModalPopupExtender只是隐藏了)
会调用名称为"OnCallBack('SetTitle')"的脚本,- -被你识破了吧这个是客户端回调,然后经过正常的
TheBeerHouse流程保存到数据源中,- -ok我们一点一点地来



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TitleTest.aspx.cs" Inherits="Test_TitleTest" %>
<%@ Register
Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit"
TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register
Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit"
TagPrefix="ajaxToolkit" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<style>

/**//*Modal Popup*/
.modalBackground {}{
background-color:Gray;
filter:alpha(opacity=70);
opacity:0.7;
}

.modalPopup {}{
background-color:#ffffdd;
border-width:3px;
border-style:solid;
border-color:Gray;
padding:3px;
width:250px;
}

.sampleStyleA {}{
background-color:#FFF;
}

.sampleStyleB {}{
background-color:#FFF;
font-family:monospace;
font-size:10pt;
font-weight:bold;
}

.sampleStyleC {}{
background-color:#ddffdd;
font-family:sans-serif;
font-size:10pt;
font-style:italic;
}

.sampleStyleD {}{
background-color:Blue;
color:White;
font-family:Arial;
font-size:10pt;
}

/**//*Popup Control*/
.popupControl{}{
background-color:White;
position:absolute;
visibility:hidden;
}

.validatorCalloutHighlight
{}{
background-color: lemonchiffon;
}
/**//*当点击修改标题区域的时候更换的背景*/
.selectTitle{}{
background-color:Gray;
}

/**//*不点或成功修改标题后的样式*/
.notSelectTitle{}{
background-color:Transparent;
}

</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div id="Title" runat=server >d
dd 
</div>
<div class="demoarea">
<div class="demoheading"></div>

<p id="Paragraph1"></p><br />
<asp:LinkButton ID="LinkButton1" runat="server" Text="Click here to change the paragraph style" />

<asp:Panel ID="Panel1" runat="server" Style="display: none">
<asp:Panel ID="Panel3" runat="server" CssClass="modalPopup" Height="72px" Width="192px">
<div>修改标题 :<br />
<input id="TitleInPut" type=text style="width: 188px; height: 21px" /><br />
<asp:Button ID="OkButton" runat="server" Text="OK" />
<asp:Button ID="CancelButton" runat="server" Text="Cancel" />
</div>
</asp:Panel>
</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server"
TargetControlID="Title"
PopupControlID="Panel1"
OkControlID="OkButton"
OnOkScript="OnCallBack('SetTitle')"
CancelControlID="CancelButton"
OnCancelScript="CanceClick('SetTitle')"
DropShadow="true"
Drag=false
PopupDragHandleControlID="Panel3"/>
</div>

<script type="text/javascript">
// The following snippet works around a problem where FloatingBehavior
// doesn't allow drops outside the "content area" of the page - where "content
// area" is a little unusual for our sample web pages due to their use of CSS
// for layout.
function setBodyHeightToContentHeight() {
document.body.style.height = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight) + "px";
}
setBodyHeightToContentHeight();
$addHandler(window, "resize", setBodyHeightToContentHeight);
</script>
</form>
</body>
</html>



//--不好意思有点长了各位是否看清楚了~~这里里用来保存数据的时 OnCallBack('SetTitle')"这个是客户端回调
赫赫我们来看看他是怎么工作的
1
后台页
2
using System;
3
using System.Data;
4
using System.Configuration;
5
using System.Collections;
6
using System.Web;
7
using System.Web.Security;
8
using System.Web.UI;
9
using System.Web.UI.WebControls;
10
using System.Web.UI.WebControls.WebParts;
11
using System.Web.UI.HtmlControls;
12
using System.Xml;
13
public partial class Test_TitleTest : System.Web.UI.Page,System.Web.UI.ICallbackEventHandler
14
//--全部都有注释这个是个人习惯建议凡是赖同胞们统统地用因为最后交接的时候生成xml了事哈哈哈
//--这里比较重要的是
//--得到原来的数据
MB.TheBeerHouse.BLL.PageState.PageState.Current.Title;
//--去取脚本
MB.TheBeerHouse.UI.Script.ManageScript.RegisterStartupScript(Page, "RageEventRegisiter");
//--保存数据
MB.TheBeerHouse.BLL.PageState.PageState.Current.Save(eventArg.Replace("SetTitle+=", "").Replace(";", ""));
我们从最简单的开始哈哈我也懒....在吃饭以前我把我的脚本类说完

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

//--又是大段的代码赫赫不好意思~~这个专题下次是最后一部分了...