Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have set require field validator for few fields of insert mode formview(AddVenue.aspx). Its working fine on click event of my Insert Button.But When I am navigate through few menus/submenu(which contains click event) of my menubar(AddVenue.aspx), all validation is getting trigger. please help me how I can avoid validation on click event of menu and Submenu.

What I have tried:

AddVenue.aspx.cs

C#
public void click_Vendor1(object sender, EventArgs e)
    {
        Vendor1.CausesValidation = false;
        Session["VendorCategory"] = "Photographers";
        Response.Redirect("SearchVendor.aspx");
        
    }
    public void click_Vendor2(object sender, EventArgs e)
    {
        Vendor2.CausesValidation = false;
        Session["VendorCategory"] = "Makeup Artists";
        Response.Redirect("SearchVendor.aspx");
        
    }
    public void click_Vendor3(object sender, EventArgs e)
    {
        Vendor3.CausesValidation = false;
        Session["VendorCategory"] = "Mehendi Artists";
        Response.Redirect("SearchVendor.aspx");

    }
    public void click_Vendor4(object sender, EventArgs e)
    {
        Vendor4.CausesValidation = false;
        Session["VendorCategory"] = "Decorators";
        Response.Redirect("SearchVendor.aspx");
    }
    public void click_Vendor5(object sender, EventArgs e)
    {
        
        Vendor5.CausesValidation = false;
        Session["VendorCategory"] = null;
        Response.Redirect("SearchVendor.aspx");
    }


AddVenue.aspx

ASP.NET
<ul>
                                                                       <li><a href='#' runat="server" id="Vendor1"   onserverclick="click_Vendor1">Photographers</a></li>
                                                                       <li><a href='#' runat="server" id="Vendor2" onserverclick="click_Vendor2">Makeup Artists</a></li>
                                                                       <li><a href='#' runat="server" id="Vendor3" onserverclick="click_Vendor3">Mehendi Artists</a></li>
                                                                       <li><a href='#' runat="server" id="Vendor4" onserverclick="click_Vendor4">Wedding Lawns</a></li>
                                                                       <li><a href='#' runat="server" id="Vendor5" onserverclick="click_Vendor5">All Wedding Vendors</a></li>
                                                           </ul>
Posted
Updated 28-Dec-16 2:50am
v2
Comments
ZurdoDev 28-Dec-16 8:22am    
Set causesvalidation = false in the aspx. By setting it in code, the validation has already run.
Member 12915152 28-Dec-16 8:27am    
Thank you RyanDev. its working.

1 solution

As mentioned in the comments, add CausesValidation=False into the aspx page as properties on the controls. By setting it in code, it is too late as the validation runs before the click events do.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900