Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Validation control and LinkButton control problem

Posted on 2006-06-30
1
474 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET MVC 2 40
Problem to refer to value 8 62
"Emulate" TAB key when press Enter Key 3 44
custom authorization on controller action and HTML in asp.net mvc 1 24
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

791 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