这是SITE.MASTER ASPX PAGE
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="Prototype4.SiteMaster" %>
&lt;%@ Register Assembly =“AjaxControlToolkit”Namespace =“AjaxControlToolkit”TagPrefix =“asp”%&gt;
alert(“JS代码一般:OK”); $(function(){ $(“#lnkShowOtherPage”)。click(function(){ alert(“OtherPagePanel length:”+ $(“#OtherPagePanel”)。length); alert(“OtherPagePanel load:”+ $(“#OtherPagePanel”)。load); $( “#OtherPagePanel”)负载( “/ EntryForms / OpenCase.aspx”); }); });
function updateClock() {
var currentTime = new Date();
var currentHours = currentTime.getHours();
var currentMinutes = currentTime.getMinutes();
var currentSeconds = currentTime.getSeconds();
// Pad the minutes and seconds with leading zeros, if required
currentMinutes = (currentMinutes < 10 ? "0" : "") + currentMinutes;
currentSeconds = (currentSeconds < 10 ? "0" : "") + currentSeconds;
// Choose either "AM" or "PM" as appropriate
var timeOfDay = (currentHours < 12) ? "AM" : "PM";
// Convert the hours component to 12-hour format if needed
currentHours = (currentHours > 12) ? currentHours - 12 : currentHours;
// Convert an hours component of "0" to "12"
currentHours = (currentHours == 0) ? 12 : currentHours;
// Compose the string for display
var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;
// Update the time display
document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}
案例管理系统
欢迎
!
[]
&LT;% - 欢迎:
! - %GT;
欢迎来客
[ 登录 ]
</asp:LoginView>
<%-- [ <asp:LoginStatus ID="MasterLoginStatus" runat="server" LogoutAction="Redirect" LogoutPageUrl="~/Logout.aspx" /> ] --%>
</div>
<div class="topNav">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"
ImageUrl="~/homeIcon.png"/>
<asp:MenuItem NavigateUrl="~/About.aspx" Text="About"
ImageUrl="~/aboutIcon.png"/>
<asp:MenuItem ImageUrl="~/contact_us_icon1.png" NavigateUrl="~/Contact.aspx"
Text="Contact Us" Value="Contact Us"></asp:MenuItem>
</Items>
</asp:Menu>
</div>
</div>
</div>
</div>
<div class="page" style="margin-top:5px;height:auto;">
<div class="right" style="border-style:solid;padding-left: 4px; padding-right:4px;">
<asp:Button ID="newsButton" runat="server" Text="News"
class="fnctButton" Height="25px" Width="70px" />
<div style="border-color: White; border-width:medium; border: medium;">
<p style="text-align:left; font-size:1.2em; color:White;">
This is a place holder for some real text that is displayed regarding news within the departement and additional links to external sites for news.
</p>
</div>
<asp:ContentPlaceHolder ID="RightNewsItem" runat="server"/>
</div>
<div class="left" style="border-style:solid;">
<asp:Button ID="functionButton" runat="server" Text="System Functions"
class="fnctButton" Height="25px" Width="170px" />
<asp:ContentPlaceHolder ID="LeftNavigation" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="middle" style= "border-bottom-style:solid;">
<asp:ContentPlaceHolder ID="MainContent" runat="server"/>
</div>
</div>
<div class="clear">
</div>
<div class="footer">
<span style="font-size: small;color: #FFFFFF;"><strong>Copyright 2011 JustRite Software Inc.</strong></span></div>
</form>
这一个是基于主页面的案例管理页面。左侧导航板上有两个按钮,它们应该按照按钮点击的中心空间加载第三页(显示或附加)。 CASE ADMIN PAGE .ASPX BELOW。
&lt;%@ Page Title =“”Language =“C#”MasterPageFile =“〜/ Site.Master”AutoEventWireup =“true”CodeBehind =“CaseAdmin.aspx.cs”Inherits =“Prototype4.CaseAdmin”%&gt; &lt;%@ PreviousPageType VirtualPath =“〜/ Account / Login.aspx”%&gt;
<div style="margin-top:20px; margin-bottom:20px;">
<p class="actionButton">
<a id="lnkShowOtherPage" href="#">Open Case</a>
</p>
<p class="actionButton"><asp:LinkButton ID="RegisterExhibitLinkButton"
runat="server" onclick="RegisterExhibitLinkButton_Click">Register Exhibit</asp:LinkButton> </p>
</div>
<div id="OtherPagePanel" style="width:auto">
</div>
本部分代表CASEADMIN页面背后的代码.CS CODES
using System;
使用System.Collections.Generic; 使用System.Linq; 使用System.Web; 使用System.Web.UI; 使用System.Web.UI.WebControls;
命名空间Prototype4 { 公共部分类CaseAdmin:System.Web.UI.Page { // string userid; // string strUsername; protected void Page_Load(object sender,EventArgs e) { // strUsername = Session [“Username”]。ToString(); } // public String AdminUserID // { //得到 // { // //返回userid; //} //}
//userid = PreviousPage.AdminID;
//Response.Redirect("~/EntryForms/OpenCase.aspx", false);
/* if (PreviousPage != null)
{
TextBox SourceTextBox =
(TextBox)PreviousPage.FindControl("UserName");
if (SourceTextBox != null)
{
userid = SourceTextBox.ToString();
}
}*/
protected void RegisterExhibitLinkButton_Click(object sender, EventArgs e)
{
Response.Redirect("~/EntryForms/AddExhibit.aspx", false);
}
}
}
这是应该按钮按钮加载的两个页面之一。我已经附上了OPENCASE表格的代码,因此它与左侧的OPENCASE LINK按钮相对应。 OPENCASE.ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OpenCase.aspx.cs" Inherits="Prototype4.EntryForms.OpenCase" %>
&lt;%@ PreviousPageType VirtualPath =“〜/ CaseAdmin.aspx”%&gt; &lt;%@ Register assembly =“AjaxControlToolkit”namespace =“AjaxControlToolkit”tagprefix =“asp”%&gt;
.casePage { 宽度:430px; 高度:314px; 背景色:#3a4f63; } .style1 { font-weight:normal; 颜色:#FFFFFF; text-align:center; } .style2 { font-weight:normal; 颜色:黑色; text-align:left; margin-left:20px; 边距:0像素;
}
.style3
{
width: 85%;
}
.style4
{
width: 175px;
background-color: #808080;
}
.style5
{
background-color: #CCCCCC;
padding-left:10px;
}
</style>
打开案例 表格
<table class="style3" align="center">
<tr>
<td class="style4">
<p class="style2">
Case ID:
</p>
</td>
<td class="style5">
<asp:TextBox ID="caseIDTextBox"
runat="server" height="22px" width="154px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style4">
<p class="style2">
Case Description:
</p>
</td>
<td class="style5">
<asp:TextBox ID="caseDescTextBox"
runat="server" height="22px" width="154px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style4">
<p class="style2">
Case Administrator ID:
</p>
</td>
<td class="style5">
<asp:TextBox
ID="caseAdminIDTextBox" runat="server" height="22px" width="154px"></asp:TextBox>
</td>
</tr>
</table>
</div>
<div>
<table class="style3" align="center">
<tr>
<td align="left">
<asp:Button ID="openCaseBotton" runat="server" Text="Open Case"
onclick="openCaseBotton_Click" />
</td>
<td align="center">
<asp:Button ID="addExhibitBotton" runat="server" Text="Add Exhibit"
onclick="addExhibitBotton_Click" />
</td>
<td align="right">
<asp:Button ID="cancelButton" runat="server" Text="Cancel"
onclick="cancelButton_Click" /></td>
</tr>
</table>
</div>
</div>
</form>
最后是OPENCASE.CS页
using System;
使用System.Collections.Generic; 使用System.Linq; 使用System.Web; 使用System.Web.UI; 使用System.Web.UI.WebControls; 使用System.Configuration;
命名空间Prototype4.EntryForms { public partial class OpenCase:System.Web.UI.Page { string adminString; protected void Page_Load(object sender,EventArgs e) { adminString =“CA123”; }
protected void openCaseBotton_Click(object sender, EventArgs e)
{
//SQL connection string
SqlDataSource CSMDataSource = new SqlDataSource();
CSMDataSource.ConnectionString = ConfigurationManager.ConnectionStrings["CMSSQL3ConnectionString"].ToString();
//SQL Insert command with variables
CSMDataSource.InsertCommandType = SqlDataSourceCommandType.Text;
CSMDataSource.InsertCommand = "INSERT INTO Filing (FilingID, FilingDesc, DateOpened, FilingPriority, AdministratorID) VALUES (@FilingID, @FilingDesc, @DateOpened, @FilingPriority, @AdministratorID)";
//Actual Insertion with values from textboxes into databse fields
CSMDataSource.InsertParameters.Add("FilingID", caseIDTextBox.Text);
CSMDataSource.InsertParameters.Add("FilingDesc", caseDescTextBox.Text);
CSMDataSource.InsertParameters.Add("DateOpened", DateTime.Now.ToString());
CSMDataSource.InsertParameters.Add("FilingPriority", null);
CSMDataSource.InsertParameters.Add("AdministratorID", adminString.ToString());
int rowsCommitted = 0;
//Try catch method to catch exceptions during insert
try
{
rowsCommitted = CSMDataSource.Insert();
}
catch (Exception ex)
{
//error message displayed when exception occurs
string script = "<script>alert('" + ex.Message + "');</script>";
Response.Write("The following Error occurred while entering the records into the database" + " " + ex.ToString() + " ");
Response.Redirect("~/ErrorPage.aspx", false);
}
finally
{
CSMDataSource = null;
}
//Where to go next if insert was successful or failed
if (rowsCommitted != 0)
{
Response.Redirect("~/CaseAdmin.aspx", false);
}
else
{
Response.Redirect("~/ErrorPage.aspx", false);
}
}
protected void addExhibitBotton_Click(object sender, EventArgs e)
{
Response.Redirect("~/EntryForms/AddExhibit.aspx", false);
}
protected void cancelButton_Click(object sender, EventArgs e)
{
Response.Redirect("~/CaseAdmin.aspx", false);
}
}
}
我想要做的就是在没有重新加载页面的情况下,在主要内容区域(中间部分)内加载相应的页面。它是一个长期的方式,但已经提供了很多成功,但我只是想知道如何将这个相同的技术应用于其他按钮点击(添加展览),因为在主页的标题中的AJAX代码中URL只有一页。如何使用主页并使用类似操作的后续页面。例如,看起来像这样的案例经理页面。
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="CaseManager.aspx.cs" Inherits="Prototype4.CaseManager" %>
这是关于调查员被分配到的案件的忠告的占位符。
<div style="margin-top:20px; margin-bottom:20px;">
<p class="actionButton"><asp:LinkButton ID="AllocateOfficerLinkButton" runat="server">Allocate Officer</asp:LinkButton> </p>
<p class="actionButton"><asp:LinkButton ID="ReallocateLinkButton" runat="server">Reallocate Officer</asp:LinkButton> </p>
<p class="actionButton"><asp:LinkButton ID="SetPriorityLinkButton" runat="server">Prioritize Case</asp:LinkButton> </p>
<p class="actionButton"><asp:LinkButton ID="OpenCaseLinkButton" runat="server">Open Case</asp:LinkButton> </p>
<p class="actionButton"><asp:LinkButton ID="RegisterExhibitLinkButton" runat="server">Register Exhibit</asp:LinkButton> </p>
</div>
我想要在案例管理页面中进行类似的事情,但是我们想知道这些代码将在主页中添加类似内容。
感谢...
答案 0 :(得分:1)
我其实只想加载表单 这是在另一个asp中创建的。页 进入主要内容区域......
我担心你所需要的不是UpdatePanel
而是“普通”AJAX将其他页面内容加载到某个元素中...使用jQuery它就像这样简单:
$("#OtherPagePanel").load("OtherPage.aspx");
其中OtherPagePanel
是.aspx
代码中某个元素的ID。
您可以通过URL将参数传递到其他页面,如果您需要发布数据,它仍然可以但需要一些额外的行 - 在这种情况下让我们知道。
编辑:
在您想要显示其他页面数据的占位符中,请输入:
<div id="OtherPagePanel"></div>
在其他占位符中有这样的链接:(在LinkButton中不需要普通的HTML链接就足够了)
<a id="lnkShowOtherPage" href="#">Show other page</a>
现在,在您的母版页的<head>
部分添加此代码并完成所有操作:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$("#lnkShowOtherPage").click(function() {
$("#OtherPagePanel").load("OtherPage.aspx");
});
});
</script>
您也可以将jQuery.min.js
文件复制到自己的服务器,并相应地更改src
。
编辑2:
为了调试将这些行添加到代码中,它将告诉出现了什么问题:
<script type="text/javascript">
alert("JS code in general: OK");
$(function() {
alert("Page load: OK");
$("#lnkShowOtherPage").click(function() {
alert("Link click: OK");
$("#OtherPagePanel").load("OtherPage.aspx");
});
});
</script>
重新加载页面,告诉我们您收到的提醒信息。
编辑3:
根据以前的调试结果,现在有了这个代码:
<script type="text/javascript">
$(function() {
$("#lnkShowOtherPage").click(function() {
alert("OtherPagePanel length: " + $("#OtherPagePanel").length);
alert("OtherPagePanel load: " + $("#OtherPagePanel").load);
$("#OtherPagePanel").load("OtherPage.aspx");
});
});
</script>
编辑4并希望持续:
为了通过点击不同的按钮将不同的页面加载到不同的div
以及您已有的所有内容,请使用以下代码:
<script type="text/javascript">
$(function() {
$("#lnkShowOtherPage").click(function() {
$("#OtherPagePanel").load("OtherPage.aspx");
});
$("#lnkShowDifferentOtherPage").click(function() {
$("#DifferentOtherPagePanel").load("DifferentOtherPage.aspx");
});
});
</script>
答案 1 :(得分:0)
是回发触发器还是异步回发触发器?
我认为您可以在脚本管理器级别将控件注册为回发或异步:
控制oControl;
ScriptManager1.RegisterAsyncPostBackControl(oControl);
你可以试试