[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1116
  • Last Modified:

asp.net attributes.add on Server

Hi,
I have a javascript function which validates an input on the client.
<Asp:button>runat=server  </asp:button>

Now in the code behind I declared on page load  attributes.add(Onclick, JavascriptFunction)
When the buton is clicked javascript works but post back happens and message box comes up and behind the aspx webpage becomes back.. When I  click the message box the page loads back again.. Is that the way it works..........I dont think so.........Where is that I am being wrong.........Can a correct example be shown
0
dotnet0824
Asked:
dotnet0824
  • 2
  • 2
1 Solution
 
pkumarraCommented:
One way of doing it is to return false from the javascript function

attributes.add("onclick", "return JavascriptFunction()")

function JavaScriptFunction()
{
//some code
return false;
}
0
 
dotnet0824Author Commented:
can a clear example be shown
0
 
pkumarraCommented:
In the serverside code do the following


attributes.add("onclick", "return JavascriptFunction()")

In the client javascript, do something like the following. The idea is to return false from the function

function JavaScriptFunction()
{
//some code
return false;
}
0
 
dotnet0824Author Commented:
thanks
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now