image postback url is fire instead of button click event

Posted by APatel under ASP.NET on 11/7/2009 | Views : 6264 | Status : [Member] | Replies : 4
Hello All,

I have one page which have a one image button and one button control and two check box below is my code..

var flag_used;
window.onbeforeunload = function (oEvent) {
if (!oEvent) oEvent = window.event;//FF & IE support
if (flag_used)
return message;
}

function Test()
{
flag_used = true;
}

<asp:UpdatePanel ID="uxscr" runat="server">
<ContentTemplate>
<TTI:TTICheckbox ID="chkmale" runat="server" Text="Male" onclick="Test();" />
<TTI:TTICheckbox ID="chkfemale" runat="server" Text="FeMale" onclick="Test();" />
<asp:ImageButton ImageUrl="../1.gif" runat="Server" PostBackUrl="~/default.aspx" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="btn1" runat="server" OnClick="btn_OnClick" Text="click"/>
//Code behind page i have define one btn_Click event

Now, When i click on check box flag_used makes "true" then after i have click on image button confrim message open then i have click on cancle button and hit submit on button click(ID of control is btn1 which define outside update)

//Output:-
what happen instead of fire the click event of button they navigate to default.aspx page.

so can you please help me as soon as possible how can i fire button click event on page?

Thanks in advance,




Responses

Posted by: SurajRane on: 11/9/2009 [Member] Starter

Up
0
Down
I am sorry friend but can you just place whole code you have with you.

I am not getting exactly what you want to do. what i understood is,

you have to show user confirm message box on click of image button only when checkbox(s) is /are checked. and when user click cancel button on confirm box; you want to avoid redirection to default.aspx..

if is it so then following code will help you



function test() 

{
return confirm("Do you want to proceed??");
}


APatel, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakhangarg on: 11/9/2009 [Member] [Moderator] Silver

Up
0
Down
Hi-

Please Post the code of this event btn_OnClick here.

Thanks & Regards
Lakhan Pal Garg

APatel, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: APatel on: 11/10/2009 [Member] Starter

Up
0
Down
Thanks for your reply,

"you have to show user confirm message box on click of image button only when checkbox(s) is /are checked. and when user click cancel button on confirm box; you want to avoid redirection to default.aspx.. "

yes, your understaning is correct but after click on cancel button on confirm message box then i want to click on submit button(full post back - outside update panel) and save value in database. but when i am click on submit button it will directly redirect to default.aspx page instead of saving value in Database.

So can you please help me how it is redirect to default.aspx page instead of fire click event?

Thank you,

APatel, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Virendradugar on: 11/12/2009 [Member] [MVP] Silver

Up
0
Down
Hi Apatel,

As requested previously by other users, kindly post your code of button click. That will help us to solve the problem.

Thanks,
Virendra Dugar

APatel, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response