I want to integrate SimpleModal in My ListView edit
action so when the user click edit
, the modal popup loaded with data through ajax
to edit the form .
My simple listview :
<asp:ListView ID="lv_familyrelation" runat="server" ItemPlaceholderID="RelationContainer" >
<LayoutTemplate>
<fieldset id="FieldSet1">
<legend>Relations</legend>
<div class="container-fluid">
<div class="row">
<div class="col-lg-4">
Code
</div>
<div class="col-lg-4">
Name
</div>
<div class="col-lg-4">
</div>
</div>
<asp:PlaceHolder ID="RelationContainer" runat="server"></asp:PlaceHolder>
<br />
<br />
<asp:LinkButton ID="lbtnInitInsert" runat="server"
CssClass="btn btn-primary btn-md white_cr"><span class="glyphicon glyphicon-plus"></span> </asp:LinkButton>
</fieldset>
</LayoutTemplate>
<ItemTemplate>
<fieldset>
<div class="container-fluid">
<div class="row">
<div class="col-lg-4">
<%#Eval("RELATION_CODE")%>
</div>
<div class="col-lg-4">
<%#Eval("RELATION_NAME")%>
</div>
<div class="col-lg-4">
<asp:LinkButton ID="lbtn_edit" runat="server"
CssClass="btn btn-primary btn-md white_cr"><span class="glyphicon glyphicon-pencil"></span> </asp:LinkButton>
</div>
</div>
</div>
</fieldset>
</ItemTemplate>
</asp:ListView>
My Bind Code :
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
lv_familyrelation.DataSource = GetRelation();
lv_familyrelation.DataBind();
}
}
From FireBug:
<div>
<fieldset id="FieldSet1">
<legend>Relations</legend>
<br>
<a id="lv_familyrelation_lbtnInitInsert" class="btn btn-primary btn-md white_cr" href="javascript:__doPostBack('lv_familyrelation$lbtnInitInsert','')"><span class="glyphicon glyphicon-plus"></span> </a>
<br>
<br>
<div class="container-fluid">
<div class="row">
<div class="col-lg-4">
Code
</div>
<div class="col-lg-4">
Name
</div>
<div class="col-lg-4">
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-lg-4">
1
</div>
<div class="col-lg-4">
Mother
</div>
<div class="col-lg-4">
<a id="lv_familyrelation_lbtn_edit_0" class="btn btn-primary btn-md white_cr" href="javascript:__doPostBack('lv_familyrelation$ctrl0$lbtn_edit','')"><span class="glyphicon glyphicon-pencil"></span> </a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-lg-4">
2
</div>
<div class="col-lg-4">
Father
</div>
<div class="col-lg-4">
<a id="lv_familyrelation_lbtn_edit_1" class="btn btn-primary btn-md white_cr" href="javascript:__doPostBack('lv_familyrelation$ctrl1$lbtn_edit','')"><span class="glyphicon glyphicon-pencil"></span> </a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-lg-4">
3
</div>
<div class="col-lg-4">
Wife
</div>
<div class="col-lg-4">
<a id="lv_familyrelation_lbtn_edit_2" class="btn btn-primary btn-md white_cr" href="javascript:__doPostBack('lv_familyrelation$ctrl2$lbtn_edit','')"><span class="glyphicon glyphicon-pencil"></span> </a>
</div>
</div>
</div>
</div>
</div>
</fieldset>
</div>
You need to use the ajax calling on linkbutton Edit Click event For this you need to add the OnClientClick function to the link button :
Ex:
OnClientClick="GetRecords();"
Here is your GetRecords Code to call the ajax Method
var param = 1;
function GetRecords() {
var params = "{'param': " + param+ "}";
$.ajax({
type: "POST",
url: "ViewBlogs.aspx/GetSample",
data: params,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.responseText);
},
error: function (response) {
alert(response.responseText);
}
});
}
function OnSuccess(response) {
if (response != "") {
$("#element-id").modal();
}
}
In C# Codebehind
[WebMethod]
public static string GetSample(int param)
{
return GetData(param);
}
So On Success if your Response is not empty then open the Modal
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With