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

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
}

Related

Update Progress is not working inside Html Table in Asp.Net

Here is my code my update progress is not wokring inside Html Table.
Means My requirement is on button click preloader should be visible stating that please wait.
But here my update progress is visible witouht button click
what should be the issue
am i doing something wrong.
I have tried lots of different thing.
I have read lots of articles regarding this many people have told that update panel is not compatible with table is that right?
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<table style="width: 920px;" border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="width: 200px;" valign="top">
<div class="admin_txt">
Skin Condition Type :
</div>
</td>
</tr>
<tr>
<td style="width: 200px;" valign="top">
<div class="admin_txt">
Intro Text :
</div>
</td>
</tr>
<tr>
<td style="width: 200px;" valign="top">
<div class="admin_txt">
Reason :
</div>
</td>
<td style="width: 700px;">
<div class="editor_posi">
<cc1:Editor ID="editor_reason" Width="650px" Height="200px" runat="server" />
</div>
</td>
</tr>
<tr>
<td style="width: 200px;" valign="top">
<div class="admin_txt">
Treatment :
</div>
</td>
<td style="width: 700px;">
<div class="editor_posi">
<cc1:Editor ID="editor_treatment" Width="650px" Height="200px" runat="server" />
</div>
</td>
</tr>
<%--<tr>
<td style="width: 200px;" valign = "top">
<div class ="admin_txt">
FAQs :
</div>
</td>
<td style="width: 700px;">
<div class = "editor_posi">
<cc1:Editor ID="editor_faq" Width="650px" Height="200px" runat="server"/>
</div>
</td>
</tr>--%>
<tr>
<td style="width: 200px;" valign="top">
<div class="admin_txt">
Treatment Recommendation:
</div>
</td>
<td style="width: 700px;">
<div class="editor_posi admin_txt_recm">
<asp:CheckBoxList ID="treatment_cbl" runat="server">
</asp:CheckBoxList>
</div>
</td>
</tr>
<tr>
<asp:UpdateProgress ID="UpdateProgress1" AssociatedUpdatePanelID="UpdatePanel2" runat="server">
<ProgressTemplate>
<div>
<td style="width: 200px;" valign="top">
<div class="admin_txt">
</div>
</td>
<td style="width: 700px;">
<div class="editor_posi">
<div class="img_cls">
<img src="images/spinner-mini.gif" />
</div>
<div class="msg_cls">
Please Wait...
</div>
</div>
</td>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</tr>
<asp:Panel ID="msg_pnl" runat="server">
<tr>
<td style="width: 200px;" valign="top">
<div class="admin_txt">
</div>
</td>
<td style="width: 700px;">
<div class="editor_posi">
<div class="img_cls">
<img src="images/check.png" />
</div>
<div class="msg_cls">
Your Record Has Been Submitted Successfully.
</div>
</div>
</td>
</tr>
</asp:Panel>
<tr>
<td style="width: 200px;" valign="top"></td>
<td style="width: 700px;">
<div class="editor_posi">
<span class="cmd_posi">
<asp:ImageButton ID="submit_btn" ImageUrl="~/images/button/submit_btn.jpg"
runat="server" OnClick="submit_btn_Click" />
</span>
<span class="cmd_posi">
<asp:ImageButton ID="reset_btn" ImageUrl="~/images/button/reset_btn.jpg"
runat="server" OnClick="reset_btn_Click" />
</span>
</div>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
Any help will be appreciated.

colspan screwing up css asp.net table

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.

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 .

How can I add methods to listview items?

below is my listview code example, while the products are populating, I want to check every single one of them against my database whether it's quantity is 0, how can add a method in code behind to do this:
I tried doing this under the onselectedindexchanged event but got the 'Object reference not set to an instance of an object.' exception :
Appreciate any help given. Thanks!
using (XXXShop db = new XXXShop ())
{
var availability = from p in db.Products
where p.Quantity == 0
select p;
(ListView_Products.FindControl("litStatus") as Literal).Text = "Unavailable";
}
ListView code:
<asp:ListView ID="ListView_Products" runat="server" DataKeyNames="ProductID"
DataSourceID="EDS_ProductsByCategory" GroupItemCount="3"
onselectedindexchanged="Page_Load">
<EmptyDataTemplate><table runat="server"><tr><td>No data was returned.</td></tr></table></EmptyDataTemplate>
<EmptyItemTemplate><td runat="server" /></EmptyItemTemplate>
<GroupTemplate><tr ID="itemPlaceholderContainer" runat="server"><td ID="itemPlaceholder" runat="server"></td></tr></GroupTemplate>
<ItemTemplate>
<td runat="server">
<table border="0" width="295">
<%-- Product pics --%>
<tr>
<td style="vertical-align: middle; text-align: center;">
<a href='ProductDetails.aspx?productID=<%# Eval("ProductID") %>'>
<image src='Catalog/Images/Thumbs/<%# Eval("ProductImage") %>' width="195" height="270" border="0">
</a>
</td>
</tr>
<tr>
<%-- Product info, description, price...etc --%>
<td style="width: 250px; vertical-align: middle; text-align: center; padding-bottom: 5px;">
<b>Price: </b><%# Eval("UnitCost", "{0:c}")%>
</td>
</tr>
<tr>
<td style="width: 250px; vertical-align: middle; text-align: center; padding-bottom: 25px;">
<asp:Literal ID="litStatus" runat="server" />
</td>
</tr>
</table>
</td>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="groupPlaceholderContainer" runat="server">
<tr ID="groupPlaceholder" runat="server"></tr>
</table>
</td>
</tr>
<tr runat="server"><td runat="server"></td></tr>
</table>
</LayoutTemplate>
</asp:ListView>
I haven't done that much with ASP.NET or used the ListView so i don't know if there might be better ways to do this, but you could add a method to your codebehind that can format your data the way you want. Like the following:
protected string FormattedQuantity(int quantity)
{
return quantity > 0 ? quantity.ToString() : "Unavailable";
}
You should then be able to use this formatter anywhere in your aspx file by doing the following:
<asp:Label ID="OccurrenceLabel" runat="server"
Text='<%# FormattedQuantity((int)Eval("Quantity")) %>' />
Check it in the ListView.ItemDataBound event

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