Client Side Hide/Show with Validation

Here is my setup...

<asp:RadioButtonList ID="rbl1" runat="server">
<asp:ListItem Text="Collect My Info" Value="0" />
<asp:ListItem Text="Skip This Step" Value="1" />
<asp:Panel ID="Info" runat="server">
<asp:TextBox ID="tb1" runat="server" />
<asp:RequiredFieldValidator ID="rfv1" runat="server" ControlToValidate="tb1" Text="Error :)" />
<asp:Panel ID="Skip" runat="server">
<asp:Literal ID="SkipText" runat="server" Text="..." />
<asp:Button ID="btn1" runat="server" Text="Continue" />

So what I would like to do is have the radio button selection hide/show the different panels depending on the selection. I have been able to come up with some javascript code that does this. However, when the panel with the form is hidden the validators still fire. I have figured out a way around the client side validation, but disabling the server side validation does not seem to be possible.

Am I going about this in the right way? This seems like such a common activity that something in the framework should exist to handle this... and if not in the framework then maybe someone has come up with a slick way of dealing with this? I know that I can hide/show this with a PostBack. However, I would like to avoid that if I can.

Your assistance is greatly appreciated.

9/16/2008 6:37:07 PM 93655 articles. 6 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 53
Get it on Google Play
Get it on Apple App Store

 you could use validation groups for each panel.  or you could use two buttons with one in panel:skip and the other in panel:info.  Then for the one in panel skip add - CausesValidation="False"

Also for RadioButtonList is runat=server so you could just use - CausesPostBack="True" then set the panel status from code

    Protected Sub rdl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

        If rdl1.selectedvalue = 1 Then
            Info.Visible = False
            Skip.Visible = True
            Info.Visible = True
            Skip.Visible = False
        End If

    End Sub

9/17/2008 1:06:20 AM

 I am looking for a solution that doesn't post back to the server in order to hide/show. I want to use client side JavaScript to hide/show the various panels. As I stated before, I have some code that will do that, but the main problem is that the Server Side validation still takes place when the form is submitted (even if the form is hidden via JavaScript).

9/17/2008 5:36:31 AM

Hi i've modified ur code...


<asp:RadioButtonList ID="rbl1" runat="server" AutoPostBack="True">	
    <asp:ListItem Text="Collect My Info" Value="0" />	
    <asp:ListItem Text="Skip This Step" Value="1" />
    <asp:Panel ID="Info" runat="server" Visible="false">	
    <asp:TextBox ID="tb1" runat="server" />	
    <asp:RequiredFieldValidator ID="rfv1" runat="server" ControlToValidate="tb1" Text="Error :)"  />
    <asp:Panel ID="Skip" runat="server" Visible="false">	
    <asp:Literal ID="SkipText" runat="server" Text="..." />
    <asp:Button ID="btn1" runat="server" Text="Continue" />
Protected Sub rbl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbl1.SelectedIndexChanged
        If rbl1.SelectedValue = 0 Then
            Info.Visible = True
            Skip.Visible = False
        ElseIf rbl1.SelectedValue = 1 Then
            Info.Visible = False
            Skip.Visible = True
        End If
    End Sub
Please click "mark as answer" if this post helped you.
9/17/2008 5:45:21 AM

On button submit pass the javascript variable back first to see which panel is visible and using validation groups for each of the panels declare which panel / validation group the submit button should validate against.


use javascript to validate.

9/17/2008 5:47:29 AM

Similar Artilces:

Highlighting web form fields on validation error events (client-side)
Have anybody eventualy did that? This is a nice feature when the web form highlights it's input fields and/or lables for that fields if they are not validated (client-side). Unfortunatly, there is no such build-in functionality in ASP.NET 2.0 validation controls. But i'm quite sure that's it's possible to make on your own, what do you think?Perhaps an additional js script shoud be added on the buttom of the page which will redefine one or more functions of original js code.Any comments, thoughts, suggestions?My LinkedIn Profile - ASP.NET C# Ninja | My News Feeds Turned out that it's quite ...

form double validation- server side and client side
Hi! I would like to make a server side validation after calling a js function that makes the client-side validation. I do not understand couple of things: 1. Do i need a server side button or  a simple HTML submit button in order to call both of the tests? 2. How do i call a server side function which is written in csharp  after i finish my JS validation (the submit  button is calling the JS function for validation first.)- is it possible to call it directly from a js function? 3. I know that my toolbox on  contains validation controls who probably are b...

Validation Controls in .NET ( Client side or server side?)
 i have a very basic question. We have all these validation controls in ( required field, range validator and others) question is the required field validator is a server side control. So does that mean that it does a post back? it client side or server side control  The only controls that post back are buttons and other inputs where you set AutoPostback="True", such as a dropdownlist or a textbox.  Another way of posting back is using an UpdatePanel and placing a trigger in it for a specified control and/or event. All controls are considered clien...

.net validators + client-side javascript validation, EnableEventValidation=false
Scenario: 1. I have a DropDownList, with 2 listitems in the .aspx. appenddatabound=true and it is tied to a datasource (via datasourceid), autopostback=false, onchange=checkIfAddNew(this) [this is the client side onchange event]The second option on this dropdown is "Add New", and the checkIfAddNew function pops up a new window and when it returns, it adds the newly created option to the dropdown. In order for this to happen without getting mad, EnableEventValidation has to be set to false in the Page directive. In addition to this dropdownlist, there is a RequiredFieldValidator...

Client Side Form Validation
What does everyone recommend for client-side form validation? I really like the Validation Application Block in conjunction with the PropertyProxyValidator in Enterprise Library, but that requires an asynchronous postback. Best Regards, Dave  What about the validator controls in You can also use them with AJAX (Validator callout)Vikram www.vikramlakhotia.comPlease mark the answer if it helped you I am using the ASP.NET MVC Framework and need something that does not require server-side controls. Regards, Dave Hi, Based on my understanding, you want to achieve client ...

Server side validation affecting client side validation
Hi there I have some client side validation that is working fine and enables/disables buttons based on user selections. This works great. However, when I perform server side validation using custom validators (like checking if the user has entered < HTML > tags or decimals in the integer boxes) and the server side validation returns isValid = false then all of the JavaScript validation that I've already done when the user clicked each control is lost. I don't understand why the enabled/disabled state of the control is not maintained.  What is calling the JavaScr...

Server Side Validation vs Client Side Validation
If your page is using client side validation for required fields, expressions, etc.     What are the benefits or disadvantages of using 'extra' server side validation for max lengths, parsing, etc? Both have their Advantages and Disadvantages... so give this a read Regards,Vinz"Code, Beer and Music" that's my way of being a programmer!How to get your Forum Question Answered | Blog | CodeASP.NET hi there, advantage: because you are using javascript some browsers for any reason may not sup...

client side validation vs server side validation
hello  i see a web form that consists of three controls :textbox,requiredfieldvalidator that weired to the textbox and a button within the click event of the button there is the following: if page.isvalid then response.redirect("Page is valid") else response.redirect("Page is not valid") end if according to my understandings: when the user does not fill anything in the textbox and then clicks the button the the page will not be submitted (i.e no request to the page will be happened or no postback will be happened) then no server event will be happened so it is sure when the us...

Client Side Form validation
OK - I agree validator controls are way kool. But I don't think they COMPLETELY replace the need for good old-fashioned hand-coded JavaScript client side form level validation. For example, say I have a form with 10 textboxes indicating possible percentage amounts for various elections in a 401K retirement account. The amounts need to add up to 100%, but only 1 box must be filled in, although all ten could be filled in. Thus we do not have a simple must enter scenario, and only with the click of the submit button can we validate that all the numbers do add up to 100%. I see no...

How to Access/Pass Server Side Array Variable at Another Web Form's Client Side
Hi All,I struck up with some intrested senario at my application development...hope some body will guide me or sends me some code snippets....Thanks in advance.Senario is like A.aspx (using C# .net 2.0 as code behind) I am going to have a array variable basically it is an TWO Dimensional array after populating the values in array I need to redirect/ reload another web form B.aspx, here i need to access the array in B.aspx client side JavaScript.How can I do this...Thanks AgainRaju Dont do a redirect but use server.transfer. That way the previous page will still hold its value, ...

avoiding redundant server-side validation after client-side validation
I see an inaccurate validation behavior on my (2.0) form. The EnableClientScript property of my validation control is set to True by default, so it performs the validation on clientside. But as soon as this occurs, it also performs the server-side validation, so the page refreshes. When the validation error occurs on clientside, it should not do the validation on serverside (I'm not calling Page.Validate() or doing Page.IsValid). In my past experience, handled this automatically, but I guess it's not always the ca...

Showing and hiding Panels on the client side?
hello, I have a couple of panels I am useing on a page to mimic a tab based navigation menu. I have been able to use linkbutton clicks to show and hide panels to simulate the tabs. Is it possible to do this on the client side rather than making trips back to the server? Is this similar to the UI validation controls that can validate input from either the client or server side, or would I have to write the script myself to accomplish this? Thanks, jigster... an asp:panel is just a <div> tag on the client-side. using view->source would have told you this.RTFM - straight ...

Client-side validation through web service
Hi,I'm trying to write a form to create a new user.  I have a couple ASP custom validators for the login name; one checks if the login name is valid (alphanumeric & correct length), and the other checks if the login name is in use.  Both of these validators make calls to an AJAX web service.  Script code follows:    function isLoginNameInUse(sender, args) {    var loginName = document.getElementById("loginName").value;    Anything.Services.UserService.IsLoginNameInUse(loginName, onUseSuccess, onUseFailure); &n...

Show/Hide Panel in Client Side
Hi. I have tow asp panels and tow html buttons to navigate between the this:document.getElementById('Panel1').style.display ='block'; document.getElementById('Panel2').style.display ='none';    the first button to show the first panel and hide the second panel . the second button had the opposite purpose. inside the panels there is asp controsl. every thing work good until I use postback  by any control in the panels,for example when I click an asp button in the panel evry panel return to the defaut style. I put this...

Web resources about - Client Side Hide/Show with Validation -

Cross-validation (statistics) - Wikipedia, the free encyclopedia
is a model validation technique for assessing how the results of a statistical analysis will generalize to an independent data set. It is mainly ...

Serena Williams eyes history, Caroline Wozniacki craves validation in women's US Open final
As Serena Williams eyes another slice of tennis history, Caroline Wozniacki is craving validation with a watershed US Open final triumph on Sunday ...

Travers Duncan asks High Court to strike down ICAC validation laws
ICAC could be sent back to the High Court as a challenge to new laws validating corruption findings looms.

Adam Scott proclaims Texas win as validation of No.1 ranking
... No.1 golfer, beating American Jason Dufner in the third hole of a play-off at the Colonial event. "It's a good feeling and maybe some validation ...

Hollande to sign gay marriage bill after Constitutional Council's validation
Hollande to sign gay marriage bill after Constitutional Council's validation People's Daily Online ... 26, 27, 28, 29, 30, 31. Jan, Feb, Mar, ...

Marketers, Get Ready for the 'Validation Era'
The public brands included has been engaging in a "friends" arms race. But there are signs that we know we overdid it.

Validation and Uncertainty
What an extraordinary conversation I had recently on Twitter. It started with Neil Killick’s statement that we should not consider our stories ...

Nvidia Icera 410 LTE Modem Passes AT&T Network Validation
... Today's news is a small step and logical precursor toward both goals, Nvidia's Icera 410 LTE and HSPA+ baseband has passed AT&T's network validation ...

Ting’s Q1 Subscriber Growth Suffers from Sprint’s New Unlocking Validation Process
Back in February, Sprint updated the process it uses to validate unlocked devices that customers want to utilize on other carriers or one of ...

[Android M Feature Spotlight] Stricter APK Validation Now Actually Checks If All Of An APK's Files Are ...
While you might file this one under "really? We weren't doing this already?" if you're a security expert, Google has added stricter validation ...

Resources last updated: 11/25/2015 12:13:30 PM