I had to format my computer and re-installed VS.net 2008
now the problem is that onclientclick doesn't work anymore
I used to have a delete button that asks user if they sure to delete, and if they dont want to delete they just cancel it and no server side event occure.
now even if user canceled the delete it still call button click event!!!!!!
what is going on wrong here?!!
any idea?
code is here
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Call Server"
OnClientClick="return confirm('Do you want to call Server Side Click Event?');"
onclick="Button1_Click"/>
</div>
</form>
</body>
</html>
The code for Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = "Server Side Called!!!";
}
}
}
I even used a break points inside one of the javascript functions, it goes there but if the function returns false it still go call server function !!!!
i even tried onclientclick="return false;" but still call the server side click event !!!
try this <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title></title>
<script type="text/javascript">
function confirmSubmit()
{
var agree=confirm("Do you want to call Server Side Click Event?");
if(agree)
return true;
else
return false;
asmgx
Member
235 Points
661 Posts
onclientclick doesn't work !!!!
Jul 26, 2009 01:59 PM|LINK
I uased to have everything working fine.
I had to format my computer and re-installed VS.net 2008
now the problem is that onclientclick doesn't work anymore
I used to have a delete button that asks user if they sure to delete, and if they dont want to delete they just cancel it and no server side event occure.
now even if user canceled the delete it still call button click event!!!!!!
what is going on wrong here?!!
any idea?
code is here
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Call Server" OnClientClick="return confirm('Do you want to call Server Side Click Event?');" onclick="Button1_Click"/> </div> </form> </body> </html>The code for Default.aspx.cs
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication1 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { TextBox1.Text = "Server Side Called!!!"; } } }mbanavige
All-Star
134971 Points
15423 Posts
ASPInsiders
Moderator
MVP
Re: onclientclick doesn't work !!!!
Jul 26, 2009 02:43 PM|LINK
By any chance did you happen to install a download manager program like FlashGet when you reloaded your pc?
I seem to recall that certain versions of that program interfered with client script in click events.
Check your add-ons and if you're running flashget, try disabling it to see if the issue clears up.
asmgx
Member
235 Points
661 Posts
Re: onclientclick doesn't work !!!!
Jul 26, 2009 11:04 PM|LINK
No any download manager been installed not FlashGet not any other download manager !!
still onclientclick doesn't work!!
izharulislam
Participant
1498 Points
296 Posts
Re: onclientclick doesn't work !!!!
Jul 27, 2009 03:50 AM|LINK
Make sure java script is enable on your machine.
You can find these settings in tools>>options>>security>>custom level
Izhar Ul Islam Khan
Microsoft Certified Technology Specialist
asmgx
Member
235 Points
661 Posts
Re: onclientclick doesn't work !!!!
Jul 27, 2009 04:34 AM|LINK
It is enabled,
I even used a break points inside one of the javascript functions, it goes there but if the function returns false it still go call server function !!!!
i even tried onclientclick="return false;" but still call the server side click event !!!
Any solutions?!
izharulislam
Participant
1498 Points
296 Posts
Re: onclientclick doesn't work !!!!
Jul 27, 2009 05:13 AM|LINK
It seems that it's a service pack.Upgrade to the latest one as this is not the intended behavior.
Izhar Ul Islam Khan
Microsoft Certified Technology Specialist
asmgx
Member
235 Points
661 Posts
Re: onclientclick doesn't work !!!!
Jul 27, 2009 05:16 AM|LINK
I have VS.net 2008 SP1 isnt this the latest one?!
Dinesh_Kumar
Member
6 Points
3 Posts
Re: onclientclick doesn't work !!!!
Jul 27, 2009 06:12 AM|LINK
Hello,
try this <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script type="text/javascript">
function confirmSubmit()
{
var agree=confirm("Do you want to call Server Side Click Event?");
if(agree)
return true;
else
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Call Server"
OnClientClick="return confirmSubmit();"
onclick="Button1_Click"/>
</div>
</form>
</body>
</html>
asmgx
Member
235 Points
661 Posts
Re: onclientclick doesn't work !!!!
Jul 27, 2009 02:56 PM|LINK
I formated my PC and installed a fresh copy of Vista with SP1 and installed VS.net 2008 the first thing from different source
but still having the same problem !!!!!!!!!
there must be something wrong here, why this is happenening to me !!!
alaa9jo
Star
11375 Points
2036 Posts
Re: onclientclick doesn't work !!!!
Jul 27, 2009 03:06 PM|LINK
try to run your code in firefox,did it work?if not,do you see any javascript errors?
Ala'a Alnajjar
----------------------------------------------------
My Webblog