Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Actually what i want to do is
i have two buttons one save another cancel
when i click save button it must save d data into database
and
when i click cancel button it must render a popup partial view containing "Are you Sure you want to cancel?"

how can i do this? help! help!!
Posted

hi you can use AJAX confirmation box
XML
<asp:Button ID="updatebutton" runat="server" Text="UPDATE" />
                             <asp:ConfirmButtonExtender ID="updatebutton_ConfirmButtonExtender"
                                 runat="server" ConfirmText="" Enabled="True" >
                             </asp:ConfirmButtonExtender>


or
refer this link

http://csharp-guide.blogspot.in/2012/06/aspnet-jquery-ui-confirm-dialog.html[^]

or

u can use this
XML
System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">var r=confirm(""Press a button"");" _
+ "if (r==true)  { alert(""You pressed OK!""); return true; }        else  {  return false ; alert(""You pressed Cancel!""); return false;  }</SCRIPT>")
 
Share this answer
 
Hi,
In cancel button use this:
ASP.NET
<asp:button id="btnCancel" runat="server" text="Cancel" onclientclick="javascript:return confirm('Are you sure you want to delete');"/>


For saving the data in database you can use the OnClick[^] event of the asp button control. You can call your procedure[^] and pass the parameters[^] in that to save the data in database.



--Amit
 
Share this answer
 
v3
@using (Html.BeginForm("t", "Test", FormMethod.Post))
{
@Html.ValidationSummary(true)
@Html.AntiForgeryToken("PostData")
@*
@Html.Label("Name")
@Html.TextBox("Name")
@Html.Label("Check")
@Html.TextBox("Check")*@
@* @Html.EditorFor(m=>m.Address.AreaName)
@Html.EditorFor(m=>m.custindi.FirstName)*@

@Html.TextBox("Name", (string)ViewBag.FBUserLastName)


<input type="submit" name="area" value="Create" id="create" />
<input type="submit" name="Areaget" value="Post" />
@* <button name="button" value="area">Area</button>
26: <button name="button" value="areaget">AreaGet</button>*@ @* @Html.ActionLink("Search", "Search", "Home", new { id = Model.album_id }) *@



}
<script type="text/javascript">
$(function () {
$('form').submit(function () {
$.ajax({
url: this.action,
type: this.method,
data: $(this).serialize(),
success: function (result) {
$('#popUp').html(result);
}
});
return false;
});
});
</script>
<script type="text/javascript">
$(function () {
$('form').submit(function () {
$("#popUp").dialog();
});
});

</script>



when i clicked the button create then it has to popup the partial view else it has to be post n database
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900