Solved

Validation control and LinkButton control problem

Posted on 2006-06-30
1
472 Views
Last Modified: 2011-10-03
I have Validation control that validates user input on TextBox control.
Also there is LinkButton on my form with OnClick event handler defined.

Now when LinkButton is clicked and Validation condition is not met then OnClick handler of LinkButton is not invoked.

Why is this happening?
How does the Validation ctrl. suppreses OnClick event of LinkButton ctrl?

When Validation condition on TextBox is OK then all works as expected.

Here is page to illustrate this:

<%@ Page Language="C#" %>
<script Language="C#" runat="server">

    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        int x = 1;
    }

</script>
<html >
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
            ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
        <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton></div>
    </form>
</body>
</html>

This code does not do anything smart, it is just for testing.
Try putting breakpoint on line "int x = 1;" to see this behavior.
0
Comment
Question by:sinisap
1 Comment
 
LVL 9

Accepted Solution

by:
zaghaghi earned 125 total points
ID: 17018133
you can set the CauseValidation of tyhe link button to False
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now