【问题标题】:AJAX Cursor - Sharepoint Visual WebpartAJAX 光标 - Sharepoint Visual Webpart
【发布时间】:2013-03-22 21:24:50
【问题描述】:

正在创建自定义 SharePoint 2010 Web 部件。

我是 AJAX 新手,所以请帮助我。

谁能给我一步一步的程序来执行以下操作:

点击按钮:

  1. 禁用按钮

  2. 显示等待屏幕/等待动画/沙漏光标

  3. 做一个很长的工作。

  4. 在文本框中显示作业已成功完成。

为了更容易理解,我在下面发布了我的代码:

以下是我的 VisualWebPart.ascx 文件:

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %> 
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="VisualWebPart1.ascx.cs" Inherits="AE_Project_Form.VisualWebPart1.VisualWebPart1" %>

<style type="text/css">
.auto-style1 {
        width: 26%;
        height: 248px;
    }

.wait{
        cursor:wait;
    }
</style>

<script type="text/javascript">
     function ShowCursor() {    
document.getElementById('btn_Submit').disabled = true;
$(this).addClass("wait");    
     }
</script>

<table class="auto-style1">
<tr>
<td class="auto-style4" colspan="2">
<asp:Button ID="btn_Submit" runat="server" OnClick="btn_Submit_Click" Text="Submit" Width="97px" Height="20px" />
</td>
</tr>

现在我的 VisualWebPart.ascx.cs 文件如下所示:

using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Publishing;
using System.Data;


namespace AE_Project_Form.VisualWebPart1
{
    [ToolboxItemAttribute(false)]
    public partial class VisualWebPart1 : WebPart
{
public VisualWebPart1()
        {
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            InitializeControl();

        }
protected void Page_Load(object sender, EventArgs e)
        {
            this.btn_Submit.Attributes.Add("onClick", "ShowMessage()");
}
protected void btn_Submit_Click(object sender, EventArgs e)
        {
//Do a long process including some Database updates etc...


//Just show a MSGBOX saying process completed 

Type cstype = this.GetType();
ClientScriptManager cs = Page.ClientScript;
if (!cs.IsStartupScriptRegistered(cstype, "PopupScript"))
{
 String cstext = "alert('Successfully Added  Project');";
cs.RegisterStartupScript(cstype, "PopupScript", cstext, true);
 }

}
}

现在我想让 webpart 做的是当一个按钮被点击时:

  1. 禁用按钮并启动等待光标

  2. 做长数据库进程

  3. 漫长的过程完成后,显示一个消息框,表明过程已完成。

但是发生的情况是按钮没有被禁用,我也没有看到等待光标。长处理器按预期需要很长时间,并且只显示一个最终消息框。

我在这里对 Javascript C# webpart 编码的理解有误吗?

【问题讨论】:

    标签: javascript asp.net ajax sharepoint web-parts


    【解决方案1】:

    我在这里的讨论中得到了答案: http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopmentprevious/thread/09f6e65c-5d8c-4516-81f1-f48c21d20ef0/?prof=required

    请查看 Jack 的最后回复...谢谢...对我有用...

    【讨论】:

      猜你喜欢
      • 2011-03-26
      • 2011-09-05
      • 2014-02-21
      • 2023-03-03
      • 2019-04-11
      • 1970-01-01
      • 2015-05-12
      • 2011-02-16
      • 1970-01-01
      相关资源
      最近更新 更多