colspan screwing up css asp.net table - c#

I created a table to organize my items on a page. The page is an edit page for a property.
I used colspan to expand rows and put a textbox within rows and set the textbox wdith to 100%, However, the textbox width still only takes the space of 1 column not 3 columns like I expected here is the code
<table align="left" style="width: 100%; float: left" class="FormFormatTable">
<tr>
<td style="width: 10%; height: 60px">Alert Name</td>
<td colspan="3" style=" ">
<asp:TextBox CssClass="inputBoxes" ID="txtBox_alertName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 10%; height: 60px;">Alert</td>
<td style="height: 60px; ">
<asp:DropDownList ID="ddl_AlertTime" runat="server">
<asp:ListItem Value="1">After</asp:ListItem>
<asp:ListItem Value="0">Immediately</asp:ListItem>
</asp:DropDownList>
</td>
<td style="height: 60px; ">
<input id="demo_vertical0" type="number"/></td>
<td style="height: 60px">
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Seconds</asp:ListItem>
<asp:ListItem>Minutes</asp:ListItem>
<asp:ListItem>Hours</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td style="width: 10%">Severity</td>
<td style=" height: 60px"" >
<asp:DropDownList ID="ddl_Severity" runat="server">
<asp:ListItem Value="1">After</asp:ListItem>
<asp:ListItem Value="0">Immediately</asp:ListItem>
</asp:DropDownList>
</td>
<td style=""> </td>
<td> </td>
</tr>
<tr style="height:60px">
<td style="width: 10%">Receipients</td>
<td colspan="3" style="">
<asp:TextBox CssClass="inputBoxes" ID="txtBox_Receipients" runat="server"></asp:TextBox>
</td>
</tr>
<tr style="height:60px">
<td style="width: 10%">Subject Title</td>
<td colspan="3" style="">
<asp:TextBox CssClass="inputBoxes" ID="txtBox_SubjectTitle" runat="server"></asp:TextBox>
</td>
</tr>
<tr style="height:60px">
<td style="width: 10%">Alert Messsage</td>
<td colspan="3" style="">
<asp:TextBox CssClass="inputBoxes" ID="txtBox_AlertMessage" runat="server"></asp:TextBox>
</td>
</tr>
<tr style="height:60px">
<td style="width: 10%; ">Notification Window</td>
<td style=" ">
<asp:TextBox CssClass="inputBoxes" ID="txtBox_NotificationWindow" runat="server"></asp:TextBox>
</td>
<td style=" "></td>
<td style="height: 60px"></td>
</tr>
<tr style="height:60px">
<td style="width: 10%; ">Notification Frequency</td>
<td style=" ">
<input id="demo_vertical" type="number"/>
</td>
<td style=" "></td>
<td style="height: 60px"></td>
</tr>
<tr style="height:60px">
<td style="width: 10%">Fields to Display in Details</td>
<td colspan="3" style="">
<asp:TextBox CssClass="inputBoxes" ID="txtBox_SubjectTitle3" runat="server"></asp:TextBox>
</td>
</tr>
</table>
css is simple just this
.inputBoxes {
width: 100%;
}
why is this?
a screenshot of my page on my computer

In you HTML
the Alert Name , Receipients ,Subject Title ,Alert Messsage ,Fields to Display in Details TextBoxs take 3 columns .
Notification Window take one columns because you don't set colspan
you must add colspan="3" to your td of notfication
<td colspan="3" style=" ">
<asp:TextBox CssClass="inputBoxes" ID="txtBox_NotificationWindow" runat="server"></asp:TextBox>
</td>

You have an extra quote in the following line (the cell definition that contains your ddl_Severity control).
<td style=" height: 60px"" >
Maybe remove this quote, and see if that fixes it.

Related

Textfield clears after calendar control postback

I have 3 text fields on my page and one calendar control. After I fill in the 3 text boxes, then click a date on the calendar control, the bottom textfield clears out, losing its value. The other 2 text boxes have their values available and do not get cleared. The textboxes all have the same properties, but I can't figure out how to keep the value in the third textbox.
<table class="auto-style2" align="center">
<tr>
<td class="auto-style4" style="text-align: right">Project Name:</td>
<td style="text-align: left">
<asp:TextBox ID="TxtProjectName" runat="server" height="32px" width="211px" MaxLength="50" OnTextChanged="TxtProjectName_TextChanged" onKeyUp="Count(this,50)" onChange="Count(this,50)" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TxtProjectName" ErrorMessage="Field is required"></asp:RequiredFieldValidator>
</td>
</tr>
</table>
<table class="auto-style2" align="center">
<tr>
<td class="auto-style4" style="text-align: right">Project Description:</td>
<td style="text-align: left">
<asp:TextBox ID="TxtDescription" runat="server" height="45px" width="211px" TextMode="MultiLine" OnTextChanged="TxtDescription_TextChanged"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TxtDescription" ErrorMessage="Field is required"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style4" style="text-align: right">Contact Name:</td>
<td style="text-align: left">
<asp:TextBox ID="TxtContactName" runat="server" Width="203px" OnTextChanged="TxtContactName_TextChanged" Height="16px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TxtContactName" ErrorMessage="Field is required"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style5">Business Area:</td>
<td class="auto-style3">
<asp:DropDownList ID="DDLBusinessArea" runat="server" style="text-align: left">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="auto-style4" style="text-align: right">Priority:</td>
<td style="text-align: left">
<asp:DropDownList ID="DDLPriority" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="auto-style4" style="text-align: right">Desired Completion Date:</td>
<td style="text-align: left">
<asp:Calendar ID="Calendar1" runat="server">
<SelectedDayStyle Font-Bold="True" />
<TodayDayStyle ForeColor="#3333FF" />
</asp:Calendar>
</td>
</tr>
Its the TxtContactName that clears.

Adding horizontal lines in <div>, or splitting <div> horizontally?

My end users have decided they want to split one piece of my GUI up. What I have currently looks like this:
What they want is this:
The code I'm using is (this is just a snippet, containing the important parts that create this part of the layout):
<div style="width:430px;border:1px solid blue;float:left;">
<asp:Panel ID="Panel6" runat="server" Height="135px" Width="410px">
<br />
<table>
<tr>
<td width="133">Claim Reprocess Required:</td>
<td width="30"><asp:DropDownList ID="cboClmReprocReq" runat="server">
<asp:ListItem>N</asp:ListItem>
<asp:ListItem>Y</asp:ListItem>
</asp:DropDownList></td>
<td width="130">Claim Reprocess Date:</td>
<td width="98">
<input type="text" id="txtClmReprocDt" class="datepicker" runat="server" style="height: 14px; width: 70px" />
</td>
</tr>
<tr>
<td width="133">Issue Closed:</td>
<td width="30"><asp:DropDownList ID="cboIssueClosed" runat="server"
OnSelectedIndexChanged="cboIssue_closed_onclick" AutoPostBack="True">
<asp:ListItem>N</asp:ListItem>
<asp:ListItem>Y</asp:ListItem>
</asp:DropDownList></td>
<td width="130">Issue Resolution Date:</td>
<td width="98">
<input type="text" id="txtIssResDt" runat="server" class="datepicker" style="height: 14px; width: 70px" />
</td>
</tr>
</table>
</asp:Panel>
</div>
<div style="width:440px;border:1px solid blue;margin-left: 440px;">
<asp:Panel ID="Panel5" runat="server" Height="135px" Width="430px">
<table>
<tr>
<td width="138"></td>
<td width="43"></td>
<td width="50"></td>
<td width="20"></td>
<td width="103"></td>
</tr>
<tr>
<td width="138">Impact Report Required:</td>
<td width="43"><asp:DropDownList ID="cboImpctRprReq" runat="server">
<asp:ListItem>N</asp:ListItem>
<asp:ListItem>Y</asp:ListItem>
</asp:DropDownList></td>
<td colspan="2" width="120">Date IR Requested:</td>
<td width="103">
<input type="text" id="txtDtIRReq" runat="server" class="datepicker" style="height: 14px; width: 70px" />
</td>
</tr>
<tr>
<td width="138">Date Range of Impact Report:</td>
<td colspan="2" width="120">
<input type="text" id="txtImpRptStDt" runat="server" class="datepicker" style="height: 14px; width: 70px" />
</td>
<td width="20">To:</td>
<td width="103">
<input type="text" id="txtImpRptEnDt" runat="server" class="datepicker" style="height: 14px; width: 70px" />
</td>
</tr>
<tr>
<td width="138"></td>
<td colspan="3">No. Of Claims Impacted:</td>
<td width="103"><asp:textbox id="txtClmsImpacted" runat="server" Width="70px"></asp:textbox></td>
</tr>
</table>
</asp:Panel>
</div>
<p></p>
<div style="border:1px solid blue;">
<asp:Panel ID="Panel7" runat="server" Height="80px" style="margin-left: 19px" Width="860px">
<br />
<table>
<tr>
<td width="200">Gatekeeper Comments:</td>
<td width="700" rowspan = "4"><asp:textbox id="Textbox_Gtkpr_Cmmnts" runat="server"
textmode="MultiLine" rows="3" Width="700px"></asp:textbox></td>
</tr>
</table>
</asp:Panel>
</div>
Everytime I mess with it, I seem to create a new formatting nightmare. I even tried a simple <hr> tag but that didn't work. I'd like to not do it by creating a table around it all if possible.
I doubt this is of any importance, but this is running in C#. However, it's really just an ASP.Net issue.
Anyone got any ideas?
you can use div
http://jsfiddle.net/MKp6f/
<div>
<table>
<tr>
<td width="133">Claim Reprocess Required:</td>
<td width="30"><asp:DropDownList ID="cboClmReprocReq" runat="server">
<asp:ListItem>N</asp:ListItem>
<asp:ListItem>Y</asp:ListItem>
</asp:DropDownList></td>
<td width="130">Claim Reprocess Date:</td>
<td width="98">
<input type="text" id="txtClmReprocDt" class="datepicker" runat="server" style="height: 14px; width: 70px" />
</td>
</tr>
</table>
</div>
<div>
<table>
<tr>
<td width="133">Issue Closed:</td>
<td width="30"><asp:DropDownList ID="cboIssueClosed" runat="server"
OnSelectedIndexChanged="cboIssue_closed_onclick" AutoPostBack="True">
<asp:ListItem>N</asp:ListItem>
<asp:ListItem>Y</asp:ListItem>
</asp:DropDownList></td>
<td width="130">Issue Resolution Date:</td>
<td width="98">
<input type="text" id="txtIssResDt" runat="server" class="datepicker" style="height: 14px; width: 70px" />
</td>
</tr>
</table>
</div>
css
div{
border-style:solid;
border-width:5px;
margin: 4px;
}
Couple of options without splitting the tables etc.
Adding another row with a <hr/> between the 2 input rows, should achieve what you are after:
...
<table>
<tr>
...
</tr>
<tr><td colspan="4"><hr /></td></tr> <!-- Added this line here -->
<tr>
...
</tr>
</table>
...
Otherwise a CSS 'fix', with a 1px background creating the line...
HTML
<div class="boxLeft">
<asp:Panel ID="Panel6" runat="server" Height="135px" Width="410px">
<table>
...
</table>
</asp:Panel>
</div>
CSS
.boxLeft {
width:430px;
border:1px solid blue;
float:left;
background: url('path-to-image') repeat-x center center;
}
.boxLeft table > tr:last-child {
margin-top 10px; // or whatever looks right
}

linkbutton are not posting back in asp.net

I have many linkbutton placed on a webform everything working correctly til yesterday. But now now my ajax extenders are not working and linkbuttons are posting back.
some of my code is
<table width="460px">
<tr>
<td colspan="2"
style=" color: #C48239; font-style: normal; font-size: 18px; font-family: 'Bookman Old Style'; text-align:center;height:22px;">
Manage Your Profile</td>
</tr>
<tr>
<td>
<asp:LinkButton ID="lnk_per_pro" runat="server" CssClass="linkButton"
PostBackUrl="~/User/Edit_profile.aspx">Edit Personal Profile</asp:LinkButton> </td>
<td>
<asp:LinkButton ID="lnk_par_pro" runat="server" CssClass="linkButton">Edit Partner's Profile</asp:LinkButton></td>
</tr>
<tr>
<td>
<asp:LinkButton ID="lnk_con_det" runat="server" CssClass="linkButton"
PostBackUrl="~/User/Edit_profile.aspx">Edit Contect Details</asp:LinkButton></td>
<td>
<asp:LinkButton ID="lnk_add_photos" runat="server" CssClass="linkButton">Add Photos</asp:LinkButton></td>
</tr>
<tr>
<td>
<asp:LinkButton ID="lnk_hob" runat="server" CssClass="linkButton"
PostBackUrl="~/User/Edit_profile.aspx">Edit Hobbies and Interests</asp:LinkButton></td>
<td>
<asp:LinkButton ID="lnk_del_pro" runat="server" CssClass="linkButton">Remove/Delete Profile</asp:LinkButton></td>
</tr>
</table></center>
</div>
</div><!-- div 2 end-->
<div id="div3">
<div id="inbox1"><b>About Myself</b>
</div>
<div id="inbox2">Partner Prefrence
</div>
</div>
<div id="div4">
<div id="indiv4"><b>Basics Information</b>
<div id="edit4">
<asp:LinkButton ID="lnk_edit" runat="server" CssClass="link"
PostBackUrl="~/User/Edit_profile.aspx"> Edit</asp:LinkButton> <img src="images/edit.png" alt="" />
</div>
</div>
<div id="indiv24">
<div id="lt"><table class="style1" >
<tr>
<td style="color: #666666; width: 180px">
Age</td>
<td style="width: 180px">
<asp:Label ID="lbl_age2" runat="server" Text="Label"></asp:Label>
</td></tr><tr>
<td style="color: #666666; width: 180px">
Mobile Number</td>
<td>
<asp:Label ID="lbl_mob2" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td style="color: #666666; width: 180px">
Height</td>
<td style="width: 180px">
<asp:Label ID="lbl_height2" runat="server" Text="Label"></asp:Label>
</td></tr><tr>
<td style="color: #666666; width: 180px">
Email Id</td>
<td>
<asp:Label ID="lbl_eml2" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td style="color: #666666; width: 180px">
Marital Status</td>
<td style="width: 180px">
<asp:Label ID="lbl_mar_sts2" runat="server" Text="Label"></asp:Label>
</td></tr>
</table></div>
a link is shown on hover of linkbutton
javascript:webforms_DoPostbackWithOption:(NewPostBackoption("","false",true,"false"));
Do you have any validation controls inside application , check once by setting the Cause validation = false to link button control .
Some times your system has changed to old time(like one year back) also the link buttons won't redirect
There may be validation controls inside application , check once by setting the Cause validation = false to link button control .

Duplicate PDF file created when button is clicked the 2nd time.

I followed this link here on how to create html table to pdf in asp.net
I followed the sample code and wired it to my button event handler, and when i clicked it, the pdf file is automatically generated in the respective file directory. But when i clicked it for the second time, it says my filename pdf has been used. I checked the file directory and there is indeed a pdf file being generated. How do i stop the duplication of pdf files when i clicked the button the 2nd time. I'm trying to convert my html table data into a pdf format. I'm wondering if i'm following the correct source.
Attempted sample code :
protected void Button1_Click(object sender, EventArgs e)
{
var document = new Document(PageSize.A4, 50, 50, 25, 25);
var output = new FileStream(Server.MapPath("MyFirstTestPDF.pdf"), FileMode.Create);
var writer = PdfWriter.GetInstance(document, output);
document.Open();
var welcomeParagraph = new Paragraph("Hello, World!");
document.Add(welcomeParagraph);
document.Close();
}
My html table in asp.net
<ul id="Report">
Case ID :
<asp:DropDownList ID="DDLCase" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DDLCase_SelectedIndexChanged"
AppendDataBoundItems="true" >
<asp:ListItem Value="-1">Select Member Report ID</asp:ListItem>
</asp:DropDownList>
<table style="width: 100%; height: 576px;">
<tr>
<th style="width: 98px; height: 49px;">Full Name :</th>
<td style="width: 351px; height: 49px; text-align: left;">
<asp:Label ID="lblFullName" runat="server" Text=""></asp:Label>
</td>
<th style="height: 49px; width: 76px">Contact :</th>
<td style="width: 185px; height: 49px; text-align: left;">
<asp:Label ID="lblContact" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<th style="width: 98px">Location :</th>
<td style="width: 351px; height: 49px; text-align: left;">
<asp:Label ID="lblLocation" runat="server" Text=""></asp:Label>
</td>
<th style="width: 76px">Type of Crime :</th>
<td style="width: 185px; height: 49px; text-align: left;">
<asp:Label ID="lblTOC" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<th style="width: 98px">Picture : </th>
<td style="width: 351px; height: 49px; text-align: left;">
<asp:Label ID="lblPicture" runat="server" Text=""></asp:Label>
</td>
<th style="width: 76px">Citizen Report Date & Time :</th>
<td style="width: 185px; height: 49px; text-align: left;">
<asp:Label ID="lblCRDT" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<th style="width: 98px">AssignTo :</th>
<td style="width: 351px; height: 49px; text-align: left;">
<asp:Label ID="lblAssign" runat="server" Text=""></asp:Label>
</td>
<th style="width: 76px">Police Report Date & Time :</th>
<td style="width: 185px; height: 49px; text-align: left;">
<asp:Label ID="lblPRDT" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<th style="width: 98px; height: 100px;">Citizen Report :</th>
<td colspan="4" style="height: 100px" text-align:"left">
<asp:Label ID="lblCR" runat="server" Text="" style="display: block; text-align: left;"></asp:Label>
</td>
</tr>
<tr>
<th style="width: 98px; height: 135px;">Police Report :</th>
<td colspan="4" style="height: 135px" text-align: "left">
<asp:Label ID="lblPR" runat="server" Text="" style="display: block; text-align: left;"></asp:Label>
</td>
</tr>
<tr>
<th style="width: 98px; height: 135px;">Official Report :</th>
<td colspan="4" style="height: 135px" text-align: "left">
<asp:Label ID="lblOR" runat="server" Text="" style="display: block; text-align: left;"></asp:Label>
</td>
</tr>
</table>
Did you close the document?
// Close the Document - this saves the document contents to the output stream
document.Close();

Field Validator Fires undesirably

I have a page with the following mark up
<%# Page Title="" Language="C#" MasterPageFile="~/CaseAdmin.master" AutoEventWireup="true" CodeBehind="AddExhibit.aspx.cs" Inherits="Prototype5.AddExhibit" %>
<h2 class="style2">
<strong><span style="color: #FFFFFF">Add Exhibit
Form</span></strong></h2>
<div style="width: 600px">
<table style="width: 303px" align="left">
<tr>
<td class="style26" style="background-color: #666666">
<p class="style5" style="color: #000000; background-color: #666666;">
<strong style="background-color: #666666">Select Existing Case ID:
</strong>
</p></td>
<td class="" style="background-color: #C0C0C0" align="left">
<asp:DropDownList ID="DropDownListcaseid" runat="server"
onselectedindexchanged="DropDownListcaseid_SelectedIndexChanged">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="DropDownListcaseid"
ErrorMessage="Please select a valid case id from the dropdown menu"
ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style4" colspan="2">
</td>
</tr>
</table>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CMSSQL3ConnectionString1 %>"
SelectCommand="SELECT [CaseID] FROM [Cases]"></asp:SqlDataSource>
</div>
<div style="width: 603px; height: 75px; ">
<table style="height: 66px; width: 598px; top: 277px; left: 268px;"
align="left">
<tr>
<td class="bold"
style="color: #000000; background-color: #666666; width: 127px;">
<strong>Exhibit Type</strong></td>
<td class="bold" style="background-color: #666666; width: 228px;">
<span style="color: #000000">Exhibit Image</td>
<td class="bold" style="background-color: #666666; width: 111px;">
<span style="color: #000000">Stored Location</span></td>
<td class="bold" style="background-color: #666666; color: #000000;">
Officer ID</span></td>
</tr>
<tr>
<td class="style32" style="background-color: #C0C0C0; width: 127px;">
<asp:DropDownList ID="exhibitTypeDropDownList" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Hard Disk</asp:ListItem>
<asp:ListItem>Pen Drive</asp:ListItem>
<asp:ListItem>Laptop</asp:ListItem>
<asp:ListItem>Palm Devce</asp:ListItem>
<asp:ListItem>Mobile Phone</asp:ListItem>
<asp:ListItem>Tablet PC</asp:ListItem>
<asp:ListItem>Pager</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="exhibitTypeDropDownList"
ErrorMessage="Please Enter the type of exhibit. eg. Harddisk"
ForeColor="Red" ondisposed="addExhibitButton_Click">*</asp:RequiredFieldValidator>
</td>
<td class="style28" style="background-color: #C0C0C0; width: 228px;">
<asp:FileUpload ID="exhibitImageFileUpload" runat="server" />
</td>
<td class="style20" style="background-color: #C0C0C0; width: 111px;">
<asp:DropDownList ID="storedLocationDropDownList" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>B-15/4</asp:ListItem>
<asp:ListItem>B-10/1</asp:ListItem>
<asp:ListItem>B-5/4</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="storedLocationDropDownList"
ErrorMessage="Please enter a valid stored location" ForeColor="Red"
ondisposed="addExhibitButton_Click">*</asp:RequiredFieldValidator>
</td>
<td class="style30" style="background-color: #C0C0C0">
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="officersSqlDataSource" DataTextField="PoliceID"
DataValueField="PoliceID" Width="79px" Height="26px">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="DropDownList1"
ErrorMessage="Please select a valid Officer id from the dropdown list"
ForeColor="Red" ondisposed="addExhibitButton_Click">*</asp:RequiredFieldValidator>
</td>
</tr>
</table>
</div>
<div style="width: 609px; height: 23px;">
</div>
<div style="margin-top:12px; width: 232px; text-align:left; font-size:1.3em;">
<asp:SqlDataSource ID="officersSqlDataSource"
runat="server"
ConnectionString="<%$ ConnectionStrings:CMSSQL3ConnectionString1 %>"
SelectCommand="SELECT PoliceID FROM PoliceOfficers"></asp:SqlDataSource>
<table align="left">
<tr>
<td align="center">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ForeColor="Red"
HeaderText="The following errors occured." />
</td>
</tr>
</table>
</div>
<div style="margin-top:12px; width: 456px;">
<table style="width: 450px" align="left">
<tr>
<td align="center" colspan="3">
<asp:Label ID="messageLabel" runat="server" BackColor="White" ForeColor="Red"
Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td align="center" style="width: 96px">
<asp:Button ID="cancelButton" runat="server" Text="Cancel"
onclick="cancelButton_Click" height="26px" width="101px" />
</td>
<td style="width: 237px">
</td>
<td align="center">
<asp:Button ID="addExhibitButton" runat="server" Text="Add Exhibit"
onclick="addExhibitButton_Click" />
</td>
</tr>
</table>
</div>
and the following interface look
I wish to perform validation on the page only when the "add exhibit button" is clicked. so in my code behind, i used an "if(page.isvalid)" to check for page validation when the button is clicked. However any other button i click fires the validation as well... I presume its because every button click tries to load a page and that calls the validator to action. how do i allow work around the validation such that, only the " add exhibit button" triggers the page validation?
You need to set the ValidationGroup property on the button and the validator. That way you can control what validation takes place.
The ValidationGroup property is an arbitrary tag that you can add to your validators and buttons to group them into logical units. So in your case, I would do this:
For your validators that are relevant for the add exhibit action.
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" ValidationGroup="AddExhibit" ...
For your button that triggers your add exhibit.
<asp:Button ID="addExhibitButton" ValidationGroup="AddExhibit"

Categories

Resources