• 【原创】ComponentArt Callback


    问题:服务端赋值给服务器控件 hidenfiled

    AddWorkStation.aspx.cs 代码片段:

    if (allWorkstations.Count >= licenseType.MaximumWorkstations)
    {
       hidMessage.Value = "Lite Edition only allows you to add " + licenseType.MaximumWorkstations.ToString() + " workstaions in system!";
    }


    前端HTML代码片段:

     1  <ComponentArt:PageView ID="workstationPageView1" runat="server">
    2 <h3>
    3 <%=Resources.Base.WorkstationName%></h3>
    4 <div>
    5 <%--value="<%=Resources.Base.Add%>"--%>
    6 <asp:TextBox ID="workstationName" runat="server" MaxLength="50" Width="300px" CssClass="required"></asp:TextBox>
    7 <input id="byNameOk" type="button" runat="server" value="<%$Resources:Base,Add %>"
    8 onclick="byNameCallbackClick()" style=" 80px" />
    9 <input type="button" value="<%=Resources.Base.Close%>" onclick="closePopupDialog(true)"
    10 style=" 80px" />
    11 </div>
    12 <br />
    13 <div>
    14 <ComponentArt:CallBack ID="byNameCallback" runat="server">
    15 <Content>
    16
    17 </Content>
    18 <ClientEvents>
    19 <CallbackComplete EventHandler="byNameCallback_Complete" />
    20 <CallbackError EventHandler="byNameCallback_Error" />
    21 </ClientEvents>
    22 </ComponentArt:CallBack>
    23 </div>
    24 <br />
    25 <div id="msg" class="MessageBottomDivStyle" style="overflow: auto; 95%; height: 150px">
    26 </div>
    27 <div>
    28 <asp:HiddenField ID="hidMessage" runat="server" />
    29 </div>
    30 </ComponentArt:PageView>


    前端JS代码片段

    View Code
     1         function byNameCallback_Complete(sender, args) {
    2 //var temMsg = $("#hidMessage").val();
    3 // var tempMessage = document.getElementById("hidMessage").value;
    4 var temMsg = document.getElementById('<%= hidMessage.ClientID %>').value;
    5
    6 //var tempMessage = $("#<%=hidMessage.ClientID%>").val();
    7 if (errorMsg == "") {
    8 if (temMsg == "") {
    9 $(msgDiv).toggleClass("successMsg");
    10 $(msgDiv).html("<%=Resources.Base.Changessaved%>");
    11 }
    12 else {
    13 $(msgDiv).toggleClass("failMsg");
    14
    15 $(msgDiv).html("<%=Resources.Base.OperationFailed %> " + "<br/>" + temMsg);
    16 }
    17 }
    18 else {
    19 $(msgDiv).toggleClass("failMsg");
    20
    21 $(msgDiv).html("<%=Resources.Base.OperationFailed %> " + "<br/>" + errorMsg);
    22
    23 }
    24 window.document.getElementById("byNameOk").disabled = false;
    25 }

    前台 temMsg 取不到值

    解决:

    在后台AddWorkStation.aspx.cs 代码片段加入 hidMessage.RenderControl(e.Output);

    View Code
    1  if (allWorkstations.Count >= licenseType.MaximumWorkstations)
    2 {
    3 hidMessage.Value = "Lite Edition only allows you to add " + licenseType.MaximumWorkstations.ToString() + " workstaions in system!";
    4 hidMessage.RenderControl(e.Output);
    5 }

    原因:由于使用了ComponentArt的Callback 控件,前台页面没有刷新,也就没有从后台取得数据,所以需要使用 hidMessage.RenderControl(e.Output) 将值发回给页面。

  • 相关阅读:
    Atitit.eclise的ide特性-------abt 编译
    Atitit.eclise的ide特性-------abt 编译
    Atitit python3.0 3.3 3.5 3.6 新特性 Python2.7新特性1Python 3_x 新特性1python3.4新特性1python3.5新特性1值得关注的新特性1Python3.6新特性2  Python2.7新特性Python 2.7的新特性
    Atitit python3.0 3.3 3.5 3.6 新特性 Python2.7新特性1Python 3_x 新特性1python3.4新特性1python3.5新特性1值得关注的新特性1Pyth
    Atitit intellij idea的使用总结attilax
    Atitit.eclipse 4.3 4.4  4.5 4.6新特性
    Atitit.eclipse 4.3 4.4  4.5 4.6新特性
    Atitit.eclipse 4.3 4.4  4.5 4.6新特性
    Atitit 软件国际化原理与概论
    Atitit 软件国际化原理与概论
  • 原文地址:https://www.cnblogs.com/successliwei/p/2331169.html
Copyright © 2020-2023  润新知