2016-06-10 49 views
0

I want to Go to click but not want to click on link but want to go to from cs file. Here IS my Code..转到Href <a href=""> From .Cs file function

<a id="editbtn" runat="server" href="#popup_edit"> 


<div runat="server" style="z-index:2" id="popup_edit" class="overlay"> 
<div class="popup"> 
    <h2>Edit Region</h2> 
    <a class="close" href="#">&times;</a> 
    <div class="content"> 
     <div class="form-group"> 
      <label class=" col-md-3 " for="RegionEdit"> 
       Region Name <span class="">*</span> 
      </label> 
      <div class=" col-sm-6 "> 
       <input type="text" id="RegionEdit" runat="server" class="form-control"> 
      </div> 
      <asp:CheckBox CssClass="checkbox-inline" ID="Active" runat="server" /> 
      <asp:Button ID="EditReg" runat="server" Text="Update" CssClass="btn btn-round btn-danger" OnClick="EditReg_Click" /> 
     </div> 
    </div> 
</div> 

I want this div to pop up from .cs file

回答

0

First, use jQuery dialog on client-side:

<script type="text/javascript"> 
function showPopup() 
{ 
    $(".popup").dialog({ 
     title: "Pop-up Dialog", 
     width: 600, // just example 
     height: 400, // just example 
     modal: true, // set to false if the popup isn't modal 
     // other properties here, including dialog('close') 
    }); 
} 
</script> 

Afterwards, change plain anchor tag to either LinkButton or Button control to trigger server-side Click event.

<asp:LinkButton ID="EditBtn" runat="server" Click="EditBtn_Click" /> 

<asp:Button ID="EditBtn" runat="server" Text="Show Popup" OnClick="EditBtn_Click" /> 

Then, handle Click event in code behind .aspx.cs file to point jQuery dialog function above:

protected void EditBtn_Click(Object sender, EventArgs e) 
{ 
    ScriptManager.RegisterStartupScript(this, GetType(), "Show Popup", "showPopup();", true); 
} 

Reference: http://www.aspdotnet-suresh.com/2014/05/show-jquery-modal-popup-from-code-behind-server-side.html(根据问题要求进行了一些更改)。

+0

Acyually我想从gridview行索引更改弹出我不想点击任何按钮。有什么我可以简单地从.CS文件中的函数去href –