Solved

Validation control and LinkButton control problem

Posted on 2006-06-30
1
471 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
Comment Utility
you can set the CauseValidation of tyhe link button to False
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

13 Experts available now in Live!

Get 1:1 Help Now