Hi

i have 3 textboxes, TBDate, TBRangeFrom, TBRangeTo.
I have use custom validation and insert code to validate date
but i need to use two different button to validate data in same webform.
For example
TBDate to use btn1 to validate and then when click will link to other form

whereas TBRangeFrom and TBRangeTo will use btn2 to validate and hence lead to another different form.. how am i going to make this happen?

because right now when i click just one button it will validate everything.=/

can you please eloborate,post yours Code.

Thx,
Chandru
<FAKE SIGNATURE>

can you please eloborate,post yours Code.

Thx,
Chandru
NetProgrammingHelp.com

<%@ Page Language="C#" MasterPageFile="~/PATS.master" AutoEventWireup="true" CodeFile="Report.aspx.cs" Inherits="Report" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <br />
    <div style="text-align: left">
    <table style="font-family: arial">
        <tr>
            <td style="width: 147px; height: 21px; text-align: right">
                <strong>Generate Report</strong></td>
            <td style="width: 176px; height: 21px">
            </td>
            <td style="width: 22px; height: 21px">
            </td>
            <td style="width: 176px; height: 21px">
            </td>
        </tr>
        <tr>
            <td style="width: 147px; height: 28px;">
            </td>
            <td style="width: 176px; height: 28px;">
            </td>
            <td style="width: 22px; height: 28px;">
            </td>
            <td style="width: 176px; height: 28px;">
            </td>
        </tr>
        <tr>
            <td style="width: 147px; height: 20px; text-align: right">
                By Date</td>
            <td style="width: 176px; height: 20px">
                <asp:TextBox ID="TBDate" runat="server"></asp:TextBox>
                <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="*" ControlToValidate="TBDate" OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator></td>
            <td style="width: 22px; height: 20px">
            </td>
            <td style="width: 176px; height: 20px">
            </td>
        </tr>
        <tr>
            <td style="width: 147px">
            </td>
            <td style="width: 176px">
                <asp:Button ID="BTNGenerateDate" runat="server" Text="Generate" Width="80px" /></td>
            <td style="width: 22px">
            </td>
            <td style="width: 176px">
            </td>
        </tr>
        <tr>
            <td style="width: 147px; height: 41px;">
            </td>
            <td style="width: 176px; height: 41px;">
            </td>
            <td style="width: 22px; height: 41px;">
            </td>
            <td style="width: 176px; height: 41px;">
            </td>
        </tr>
        <tr>
            <td style="width: 147px; text-align: right">
                By Range</td>
            <td style="width: 176px">
            </td>
            <td style="width: 22px">
            </td>
            <td style="width: 176px">
            </td>
        </tr>
        <tr>
            <td style="width: 147px; text-align: right">
                <em>From</em></td>
            <td style="width: 176px">
                <asp:TextBox ID="TBRangeFrom" runat="server"></asp:TextBox></td>
            <td style="width: 22px; text-align: right">
                <em>To</em></td>
            <td style="width: 176px">
                <asp:TextBox ID="TBRangeTo" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <td style="width: 147px">
            </td>
            <td style="width: 176px">
                <asp:Button ID="BTNGenerateRange" runat="server" Text="Generate" Width="80px" /></td>
            <td style="width: 22px">
            </td>
            <td style="width: 176px">
            </td>
        </tr>
    </table></div>
    <br />
</asp:Content>

Hi i think with a picture you might understand what I'm trying to ask.=) cause Im usually not good at phrasing question.

Use a custom validator and validate it in code based on the postback button.

Use ValidationGroup property.

The ASP.NET controls have a ValidationGroup property that, when set, validates only the validation controls within the specified group when the control triggers a post back to the server.

commented: I always figured there was a better way. Now i know :) +17

Use ValidationGroup property.

The ASP.NET controls have a ValidationGroup property that, when set, validates only the validation controls within the specified group when the control triggers a post back to the server.

yea i did saw that so i just type under validation group. like the textbox i want to validate and the btn when click then it validate or???

The TextBox, Button controls should have same ValidationGroup. If you are using ValidationSummary, then you need to specifiy the ValidationGroup for it.

For your requirement, TBDate to use btn1 should have a ValidationGroup. TBRangeFrom, TBRangeTo and btn2 should have another ValidationGroup.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.