views:

39

answers:

0

hi, i have a situation where i have to halt a program and for this i need to provide the halt reason.I have a gridview where i can select multiple items by checkbox.i need a java script which will validate that halt reason text box has some text while i click the halt button to halt the selected items.Here is my gridview

 <asp:GridView ID="gvCampaignHalt" runat="server" 
        AutoGenerateColumns="False" BorderStyle="None" GridLines="None" 
        EnableTheming="False" 
        >
    <RowStyle CssClass="tr_style3" />
    <Columns>
        <asp:TemplateField>
            <ItemTemplate>
                <asp:CheckBox ID="ChkbxSectHalt"   runat="server" />

            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="Campaign_id" 
            HeaderText="Campaign ID " SortExpression="Campaign_id" >
            <HeaderStyle Width="100px" />
        </asp:BoundField>
        <asp:BoundField DataField="Campaign_Name" 
            HeaderText=" Campaign Name " SortExpression="Campaign_Name" >
            <HeaderStyle Width="150px" />
        </asp:BoundField>
        <asp:BoundField DataField="Parent_Campaign" 
            HeaderText=" Parent Campaign " SortExpression="Parent_Campaign" >
            <HeaderStyle Width="150px" />
        </asp:BoundField>
        <asp:BoundField DataField="Start_Date" 
            HeaderText=" Start Date " SortExpression="Start_Date" >
            <HeaderStyle Width="100px" />
        </asp:BoundField>
        <asp:BoundField DataField="End_Date" HeaderText=" End Date " 
            SortExpression="End_Date" >
            <HeaderStyle Width="100px" />
        </asp:BoundField>
        <asp:BoundField DataField="Status" 
            HeaderText=" Status " SortExpression="Status" >
            <HeaderStyle Width="150px" />
        </asp:BoundField>


        <asp:TemplateField HeaderText="Target Segment">
            <ItemTemplate>
            <%--<a href="BLOCKED SCRIPTopenPopup('Target-Segment.aspx?id=<%# Eval("ID") %>')">View</a>
        </ItemTemplate>--%>
                <%--<asp:HyperLink ID="hlTargetSegment"   runat="server" NavigateUrl='<%#"javascript:popUp("+Eval("Campaign_id") + ")"%>'>View

+ ","+Eval("Campaign_Name")--%> '>View

        <asp:TemplateField HeaderText="Halt Reason">
            <ItemTemplate>
                <asp:TextBox ID="txtHaltReason" runat="server" ></asp:TextBox>
            </ItemTemplate>
        </asp:TemplateField>

    </Columns>
    <HeaderStyle CssClass="content_table_heading" />
    <AlternatingRowStyle CssClass="tr_style4" BorderStyle="None" />
</asp:GridView>

i also have a java script to check wherther at lest one checkbox is checked or not....

<script type="text/javascript" >
var TargetBaseControl = null;

window.onload = function() {
    try {
        //get target base control.
        TargetBaseControl =
       document.getElementById('<%= this.gvCampaignHalt.ClientID %>');
    }
    catch (err) {
        TargetBaseControl = null;
    }
}

function TestCheckBox() {

    if (TargetBaseControl == null) return false;

    //get target child control.
    var TargetChildControl = "ChkbxSectHalt";


    //get all the control of the type INPUT in the base control.
    var Inputs = TargetBaseControl.getElementsByTagName("input");

    for (var n = 0; n < Inputs.length; ++n)
    {
        if (Inputs[n].type == 'checkbox' &&
        Inputs[n].id.indexOf(TargetChildControl, 0) >= 0 && Inputs[n].checked) 
            return HaltConfirmation();
        }


    alert(' Select at least one checkbox!');
    return false;
}

kindly help me....