gpt4 book ai didi

c# - 是否可以在更新面板之外引用链接机器人作为更新触发器?

转载 作者:太空宇宙 更新时间:2023-11-03 14:23:45 27 4
gpt4 key购买 nike

这是站点。主ASPX页面

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="Prototype4.SiteMaster" %>


<%@注册Assembly =“ AjaxControlToolkit”命名空间=“ AjaxControlToolkit” TagPrefix =“ asp”%>




        
        
            alert(“一般的JS代码:确定”);
            $(函数(){
                $(“#lnkShowOtherPage”)。click(function(){
                    alert(“ OtherPagePanel length:” + $(“#OtherPagePanel”)。length);
                    alert(“ OtherPagePanel load:” + $(“#OtherPagePanel”)。load);
                    $(“#OtherPagePanel”)。load(“ / 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;
}





    
    
        
            
                案件管理系统
            
            
                
            
            
                
                    
                        
                            欢迎
                                !
                        []
                            <%-欢迎使用:
                             !-%>
                        
                        
                            欢迎来客
                            [ 登录 ]
                        

                </asp:LoginView>
<%--&nbsp;&nbsp; [&nbsp;<asp:LoginStatus ID="MasterLoginStatus" runat="server" LogoutAction="Redirect" LogoutPageUrl="~/Logout.aspx" />&nbsp;]&nbsp;&nbsp;--%>

</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>





这是基于主页面的案例管理页面。左侧导航窗格上有两个按钮,这些按钮应按所选择的按钮在中心空间中加载第三页(大写或附加)。下面的案例管理页面.ASPX。

<%@页面标题=“”语言=“ C#” MasterPageFile =“〜/ Site.Master” AutoEventWireup =“ true” CodeBehind =“ CaseAdmin.aspx.cs” Inherits =“ Prototype4.CaseAdmin”%>
<%@ PreviousPageType VirtualPath =“〜/ Account / Login.aspx”%>






<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编码)的代码。

using System;


使用System.Collections.Generic;
使用System.Linq;
使用System.Web;
使用System.Web.UI;
使用System.Web.UI.WebControls;

命名空间Prototype4
{
    公共局部类CaseAdmin:System.Web.UI.Page
    {
        //字符串用户ID;
        //字符串strUsername;
        受保护的void Page_Load(对象发送者,EventArgs e)
        {
            // strUsername = Session [“ Username”]。ToString();
        }
        //公共字符串AdminUserID
        // {
        //取得
        // {
        // //返回用户ID;
        //}
        //}

        //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链接按钮相对应。 OPENCASE.ASPX

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OpenCase.aspx.cs" Inherits="Prototype4.EntryForms.OpenCase" %>


<%@ PreviousPageType VirtualPath =“〜/ CaseAdmin.aspx”%>
<%@注册程序集=“ AjaxControlToolkit”名称空间=“ AjaxControlToolkit” tagprefix =“ asp”%>





    
    
        .casePage
        {
            宽度:430px;
            高度:314像素;
            背景颜色:#3a4f63;
        }
        .style1
        {
            font-weight:正常;
            颜色:#FFFFFF;
            文本对齐:居中;
        }
        .style2
        {
            font-weight:正常;
            颜色:黑色;
            文字对齐:左;
            左边距:20px;
            margin-top:0px;

    }
.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
{
    公共局部类OpenCase:System.Web.UI.Page
    {
        字符串adminString;
        受保护的void Page_Load(对象发送者,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>






我想在管理页面的情况下做类似的事情,但是想知道在主页面中代码会增加什么。

谢谢...

最佳答案

我实际上只是想加载一个表格
  在另一个ASP中创建的。页
  进入主要内容区域...


我担心您需要的不是UpdatePanel而是“普通” AJAX,它将其他页面内容加载到某个元素中。使用jQuery就像这样简单:

$("#OtherPagePanel").load("OtherPage.aspx");


其中 OtherPagePanel.aspx代码中某些元素的ID。

您可以通过URL将参数传递给另一个页面,如果您需要发布数据,仍然可以,但是需要一些额外的行-在这种情况下请告知我们。

编辑:

在要显示其他页面数据的占位符中,请执行以下操作:

<div id="OtherPagePanel"></div>


在其他占位符中有这样的链接:(不需要LinkBut​​ton,普通的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>

关于c# - 是否可以在更新面板之外引用链接机器人作为更新触发器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4647554/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com