Ads

Captured Technology - Blog

ASP.Net Form Issues Solved

ASP.Net Form Issues Solved

I was working on a ASP.Net form this week that created several issues that I need to research to solve. Radio Buttons on the page were making all other controls undetectable within the code. Validation text was wrapping from next to the validated control to underneath the control. And the Reset button on the page was causing validation to occur which is not desirable.

Radio Button List

I was able to solve the issue of radio buttons on the page affecting all other controls by wrapping the buttons into a radio button list.

<asp:radiobuttonlist id="rdSpecificInvoiceInfo" runat="server">
     <asp:listitem id="rdSpecificInvoiceInfoY" runat="server" value="Yes" />
     <asp:listitem id="rdSpecificInvoiceInfoN" runat="server" value="No" />
</asp:radiobuttonlist>

Validation Text Wrapping

The second issue was solved by adding a style tag to the validation control itself.

<asp:RequiredFieldValidator style="white-space:nowrap" 
ID="rfvYourName" visible="False" runat="server" ErrorMessage="Your Name is Required"
Font-Bold="True" Font-Italic="False" ControlToValidate="txtYourName"
Enabled="True"></asp:RequiredFieldValidator>
 

No Validation on Reset

The reset button was the simplest but most difficult to solve. I found one article detailing the use of validation groups which did nothing but waste time in the implementation. Finally I found some information online about setting one property on the button, CausesValidation.

<asp:Button ID="bReset" CausesValidation="False" CssClass="form_control" 
runat="server" ToolTip="Reset" Width="60" Text="Reset" />

Blog Directory

Latest technology news.
 Patrick Stevens
 554  246497  11/15/2024

Translate

Categories

Blog Calendar