2013-11-21 47 views
1

我试图在更新弹出控件的值后显示一个模式弹出窗口,全部在客户端。模式弹出,更新面板和客户端更新

单击网格行中的链接按钮。使用该行的一些数据,我调用一个javascript函数来填充模态弹出窗口的控件并显示它。莫代尔弹出弹出正常,但控制都是空白的。 (删除UpdateMode =“Consitional”不起作用)。 我已经删除了所有格式行以保持代码简短。

<asp:UpdatePanel runat="server" ID="upnlNewIDS" RenderMode="Inline" UpdateMode="Conditional"> 
    <ContentTemplate> 
     <asp:Panel runat="server" ID="divReassign" Width="350" Style="border:solid 2px navy;display:none;background: url(../assets/images/bg3.gif);"> 
      <asp:Label runat="server" ID="lblFacilityCount" /> 
      <asp:Label runat="server" ID="lblCurrIDSName_BK" /> 
      <asp:Label runat="server" ID="lblCurrSiteName" /> 
      <asp:Button runat="server" ID="btnSOK" Text="OK" Width="75" /> 
      <asp:Button runat="server" ID="btnCancel" Text="Cancel" Width="75" /> 
     </asp:Panel> 
     <ajaxToolkit:ModalPopupExtender runat="server" 
      ID="mpeNewIDS" 
      TargetControlID="btnFake" 
      BackgroundCssClass="backgrondModal" 
      DropShadow="true" 
      BehaviorID="mpeNewIDS" 
      PopupControlID="divReassign" 
      CancelControlID="btnCancel" /> 
     <asp:Button runat="server" ID="btnFake" Style="display:none" /> 
    </ContentTemplate> 
</asp:UpdatePanel> 

这是显示的链接行的模板:

<a id='a_<%# Eval("IDSID") %>' href="javascript:void(0);" 
    onclick="PopulateView('<%# Eval("idsid") %>', '<%# Eval("cnt" %>', '<%# Eval("idsname") %>', '<%# Eval("sitename") %>')">Reassign</a> 

的Javascript: 我跟踪代码,这个功能拥有所有正确的参数值。

function PopulateView(idsid, cnt, idsname, sitename) { 
    lblCurrIDSName_BK = document.getElementById('<%=lblCurrIDSName_BK.ClientID %>'); 
    lblFacilityCount = document.getElementById('<%=lblFacilityCount.ClientID %>'); 
    lblCurrSiteName = document.getElementById('<%=lblCurrSiteName.ClientID %>'); 

    lblCurrIDSName_BK.value = idsname; 
    lblCurrSiteName.value = sitename; 
    lblFacilityCount.value = cnt; 
    ShowNewIDSModalPopup(); 
} 
function ShowNewIDSModalPopup() { 
    $find("mpeNewIDS").show(); 
    return false; 
} 

function HideNewIDSModalPopup() { 
    $find("mpeNewIDS").hide(); 
    return false; 
}  

当单击网格行的链接,我称之为 “PopulateView( 'A', 'B', 'C', 'd')”,其中a,b,c,d是从选择该行的列。

回答

0

在.aspx页面中使用此项。它会在你的linkbutton点击事件时打开弹出窗口。像

<asp:TemplateField HeaderText="Verified Count"> 
    <ItemTemplate> 
     <asp:LinkButton ID="verifycount" runat="server" OnClick="verifycount_Click"> <%# Eval("VerifiedCount")%> </asp:LinkButton> 
    </ItemTemplate> 
</asp:TemplateField> 

配置链接按钮,这是你的弹出窗口。在.aspx.cs页

<asp:Button ID="btn" runat="server" style="display:none" /> 
<cc1:ModalPopupExtender ID="popup_verifyInventory" runat="server"     PopupControlID="verifyInventory_popup" TargetControlID="btn"> 
</cc1:ModalPopupExtender> 

<asp:panel runat="server" ID="verifyInventory_popup" BorderStyle="solid"   BorderWidth="1px"> 
    <table width="100%" cellpadding="1" cellspacing="1" align="center"> 
     <tr> 
      <td colspan="3"><strong> Verify Asset Details </strong></td> 
      <td><asp:ImageButton id="close" TabIndex="1" runat="server" ImageAlign="Right" ImageUrl="~/Images/remove.gif" Height="30" Width="30" ToolTip="Close" OnClientClick="HidePopUp_verifyInventory()"/></td> 
     </tr> 
     <tr> 
      <td colspan="4"> 
      <asp:GridView ID="grdgrid" runat="server" 
            AutoGenerateColumns="true" Width="290px" > 
      </asp:GridView> 
      </td> 
     </tr> 
    </table> 
</asp:panel> 

,写链接按钮单击事件像

protected void verifycount_Click(object sender, EventArgs e) 
    { 
     //your code place here 
     //it will show your popup 
     popup_verifyInventory.Show(); 
    } 

编写JavaScript像

<script type="text/javascript"> 
     var ShowVerifyInventory = '<%=Your popup control ID %>'; 
     function ShowPopUp_verifyInventory() { 
      $find(ShowVerifyInventory).show(); 
     } 

     var HideVerifyInventory = '<%=Your popup control ID %>'; 
     function HidePopUp_verifyInventory() { 
      $find(HideVerifyInventory).hide(); 
     } 
</script> 

弹出将在GridView控件绑定值。

+0

我想做这个客户端。我的网格不在里面弹出。为了响应点击网格中每一行的,我想调用一个javascript函数,将它从选定行中传递给一些值,并弹出打开弹出窗口中分配给标签的值。 – NoBullMan

0

我放弃了做这个客户端,并在服务器端做了,使用RowDataBound的网格添加alink按钮,并将我需要的列值分配给linkbutton的“Command Arguments”。