Go to DotNetFunda.com
 Online : 42 |  Welcome, Guest!   Login
 Skip Navigation Links Home > Forums > ASP.NET > image postback url is fire instead of button click event
  Win at least 8 gifts every month now! >> Top Performers of this month.   


Notice: If page content has been copied from other sources without proper permission, kindly let us know with details from where it has been copied for further action.

ASP.NET Forum



image postback url is fire instead of button click event

Author: APatel | Posted on: 11/7/2009 | Category: ASP.NET | Views: 268 |  Print |
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,

Reply



Interesting?   Share and Bookmark this


 Responses
SurajRane  
Posted on: 11/9/2009 1:52:59 AM
Reply

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??");
}


Lakhangarg  
Posted on: 11/9/2009 6:14:31 AM
Reply

Hi-

Please Post the code of this event btn_OnClick here.

Thanks & Regards
Lakhan Pal Garg


APatel  
Posted on: 11/10/2009 12:13:01 AM
Reply

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,


Virendradugar  
Posted on: 11/12/2009 3:25:37 AM
Reply

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


Latest Questions

 Ask a Question


Advertisement

About Us | The Team | Contact Us | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
All rights reserved to DotNetFunda.Com. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks.
(Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher)