C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

Clientside confirmation


Posted Date: 03 Nov 2009      Posted By: karunya      Member Level: Silver     Points: 1   Responses: 4



hi friends,

<asp:Button ID="btnSubmit" runat="server" onclick="btnSubmit_Click"
Text="SaveTransaction" OnClientClick="return confirm('Are you sure you want to Save?');" />



protected void btnSubmit_Click(object sender, EventArgs e)
{

}

above is my code.On confirmation if user clicks
1. ok button it should redirect to another page(say next page) along with a value(querystring)
2. cancel button it should redirect to another page(previous page)


thanks in advance,
karunya.





Responses

Author: greeny_1984    03 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Hi,

You can write a javascript function check this code




function confirmcode()
{

if(confirm('Are you sure you want to quit'))
{
window.location.href="page2.aspx";

}
else
{
window.location.href="previous.aspx";
}

}


Regards,
Greeny_1984

Rate this Response[Excellent/Good/Poor]
FRESHERS check this link
Need help from me join here



Author: Lakhan Pal    03 Nov 2009Member Level: DiamondRating: 4 out of 54 out of 54 out of 54 out of 5     Points: 6

Hi karunya -

In this Case you need to write a JavaScript Function and Use one hidden field to save the value for url.

For Example

<asp:Button ID="btnSubmit" runat="server" onclick="btnSubmit_Click"
Text="SaveTransaction" OnClientClick="ConfirmAction();" />
<asp:HiddenField ID="hdnValue" runat="server">

function ConfirmAction()
{
var hdnValue= document.getElementById('<%=hdnValue.ClientID%>');
if(confirm('Are you sure you want to Save?')==true)
{
hdnValue.value="Ok";
}
else
hdnValue.value="Cancel";
}

cs Page Code:
protected void btnSubmit_Click(object sender, EventArgs e)
{
if(hdnValue.value=="Ok")
server.transfer ("FirstURL")
else
server.transfer ("SecondURL")
}


Please rate this answer if it helped you.
Thanks & Regards
Lakhan Pal Garg
Free Code Snippets



Author: Anuraj    03 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

You need a javascript function for this


function showConfirm()
{
var result = confirm("Are you sure?");
if(result)
{
//Redirect to Page2
}
else
{
//Redirect to Page2
}
}


Thanks
Anuraj
THIS POSTING IS PROVIDED "AS IS" WITH NO WARRANTIES, AND CONFERS NO RIGHTS.
BEWARE OF BUGS IN THE ABOVE CODE; I HAVE ONLY PROVED IT CORRECT, NOT TRIED IT.
dotnetthoghts



Author: rajanigrandhi    04 Nov 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

function confirm(){if(confirm('Are you sure you want to quit')){window.location.href="page2.aspx";}else{window.location.href="previous.aspx";}}


Post Reply
You must Sign In to post a response.
Next : Asp Menu
Previous : Problem with Alert message window's Position
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use