.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

What is the easiest way to reset all the values of controls on a web form (vb.net) to their defaults

Posted By:      Posted Date: August 23, 2010    Points: 0   Category :ASP.Net

What is the easiest way to reset all the controls on a web form.  Can I set "veiw state" to false for all of the controls with one command, do a response-redirect to its own page, and set view state back to true.  What is the easiest way to do it.



View Complete Post

More Related Resource Links

ASP.NET: Develop Polished Web Form Controls the Easy Way with the .NET Framework


Pre-built custom controls make application design easier and faster and allow you to maintain UI consistency. However, prepackaged controls can be big and slow, and are OS-specific. For those who don't want to use prepackaged controls, Visual Studio .NET provides controls for Web Forms similar to those found in Windows Forms, including label and textbox, and new additions such as the DataGrid, all of which you can customize. If you want to design your own controls, the .NET Framework provides inheritable classes that take care of all the nasty stuff you want to avoid, including page lifecycle, maintaining state across invocations, and browser detection. This article discusses these concepts, as well as eventing, rendering, and client-side scripting.

David S. Platt

MSDN Magazine June 2002

ASP.NET: Selectively Enable Form Validation When Using ASP.NET Web Controls


Sometimes the extra controls that come with Visual Studio .NET can be a bit inflexible or they just don't provide enough functionality or flexibility for all situations. The ASP.NET form validation controls, while powerful and easy to use, require that the entire page be valid before it's submitted back to the server. Through the use of the new object-oriented features of Visual Basic .NET, it is possible to extend their functionality to overcome this limitation. This article tells you how and helps you decide when it's a good idea to keep validation on the client and when you'd be better off disabling it.

James M. Venglarik II

MSDN Magazine April 2002

Enabling/disabling input controls in a form

I am writing a ASP.NET UserControl and I am trying to incorporate JQuery into this.
The control is a simple form with a few input fields (text, checkbox, select, radio).
The first element in the form is a checkbox. Upon clicking this checkbox I want the all the input elements in the form (except the checkbox control itself) to be enable/disable. I tried writing some of this code but my solution was not getting me anywhere.
Below is the ASP.NET form code. I'd appreciate the help with some code or pointers into what I am doing wrong.
 <asp:Panel ID="pnlInputControls" runat="server">
    <table style="width:100%;">
            <td style="width:50%">
                <asp:CheckBox ID="chkBenefitName" runat="server" Checked="true" TextAlign="Right" ClientIDMode="AutoID" style="padding:0 0 0

how do i use javascript to change values of controls inside a gridview

i have 2 labels (lblRate,lblTotal) and a textbox (txtQuantity) in a itemtemplate of a gridview.I want to calculate the products of rate and quantity and show it in Total as the textbox loses focus...i cant use textchanged because i dont want the page to postback.How do i use javascript to achieve this??Please Help Urgently....<asp:TemplateField HeaderText="Rate">                <ItemTemplate>                    <asp:Label ID="lblRate" runat="server" Text='<%# Eval("Rate") %>' />                </ItemTemplate>            </asp:TemplateField> <asp:TemplateField HeaderText="Quantity">                <ItemTemplate>                    <asp:TextBox ID="txtQty" runat="server" />                </ItemTemplate>&

Problem getting values next to each other from two separate CheckBoxList controls

Hi, I am using three CheckBoxList controls in ASP.NET Wizard control. CheckBoxList controls: <asp:CheckBoxList ID="cblLondonDates" runat="server" DataSourceID="SqlDataSource1" DataTextField="ShowDate" DataTextFormatString="{0:G}" DataValueField="ShowDate" ForeColor="#333333" CssClass="ShowDateMargin"></asp:CheckBoxList> <asp:CheckBoxList ID="cblSingleL" runat="server" DataSourceID="SqlDataSource2" DataTextField="size8" DataValueField="size8" ForeColor="#333333"> </asp:CheckBoxList> <asp:CheckBoxList ID="cblHalfL" runat="server" DataSourceID="SqlDataSource2" DataTextField="size6" DataValueField="size6" ForeColor="#333333"></asp:CheckBoxList>   cblLondonDates chackboxlist control shows dates generated from SQL table. cblSingleL an cblHalfL show table sizes. On ASP page they come up as following: 12/03/2011(checkboxlist-ID="cblLondonDates")-Single(checkboxlist-ID="cblSingleL") - Half(checkboxlist-ID="cblHalfL") 03/03/2012(checkboxlist-ID="cblLondonDates")-Single(checkboxlist-ID="cblSingleL") - Half(checkboxlist-ID="cblHalfL") 05/10/2010(checkboxlist-ID="cblLo

this.controls.add - not always adding to parent form

My current code (snippet below) iterates through user info and adds the same custom control to a form based on how many "Meals" (1-6) the user has selected.  It appears that all even # controls (the second, fourth and sixth) are added to the previously added control, rather than the parent form, when I later try to dispose the controls by iterating through this.controls, only 1, 3 and 5 appear, the others appear as children to 1, 3 & 5. I've reduced controls size, etc. to make sure they're not overlapping (if that can force inheritence?) but no luck.  Anyone have suggestions on what to look at or other guidance? public void drawMealPanel(Meal m, int x, int y) { Controls.MealDisplay md = new Controls.MealDisplay(m); md.Name = m.name; md.Tag = m.id.ToString(); md.Left = x; md.Top = y; md.DragDrop += new System.Windows.Forms.DragEventHandler(this.MealView_DragDrop); md.DragEnter += new System.Windows.Forms.DragEventHandler(this.MealView_DragEnter); this.Controls.Add(md); }

mdi form sub controls transparency C#

Hey there! Im having a panel with 2 Textboxes and a picturebox with a round corner image. The Panel is transparent so that the picturebox gives a round corner background(see image link) Now, my problem ist, that i need a mdiclient as form, and now the panel transparency doesn't work anymore. Making the panel color like the background color will not work, because i use a gradient as mdiclient background. Hope anyone can help me and understand what im trying to tell you. Image: http://img801.imageshack.us/img801/5325/unbenanntrr.jpg Thanks in advance

Cannot retrieve values of dynamically generated controls

Hi All, I am creating a user control which contains checkboxes and labels that needs to be created on fly. The dynamic generation of these controls depend on the values retreived from a SPlist. I have several panels that display items queried from the list on the basis of a selection criteria. On a button click event I need to capture all the selected values from the controls that were generated dynamically.  When I traverse each dynamic control that I added to the panel, I dont see their values. I tried using recursive retrieval of the control from the page as well but it just behaves crazy, it treats a radio button as a checkbox and returns a value that I am not looking for. I am not using the the page_load() or any other event, I use the button handler on my custom method. I was thinking for ViewState, ControlsState or SessionState. I assume ViewState may not work on this as the dynamically generated controls need to be in the page_load event. Please guide as this getting way more complicated than what I had ever thought of it to be.

Passing values to same kind of controls

Hi all, I have two user controls attached to my Master page. (vb.net) These user controls display ads, and the pnly difference between them is the width of the ads they should diplay. Is there some way in which I can just register one user control, but use it twice, and then pass different integers to them? In other words, instead of having this: @ Register Src="Ads240.ascx" TagName="Ads240" TagPrefix="uc240" %> @ Register Src="Ads120.ascx" TagName="Ads120" TagPrefix="uc120" %> I'd only like to register one of them: @ Register Src="Ads.ascx" TagName="Ads" TagPrefix="ucAds" %>   Then from the .aspx page I'd like to have two of these:  <ucAds:Ads ID="Ads" runat="server" /> but kind of send different values to them (like "Usercontrolparameter=120") How do I do this? I have looking at properties and the like, but I don't know if they can let me reuse the user control file with different values. Thanks for any help! /Pettrer  

how to pull values to asp.net controls from publishing controls

HI, I'm using Sp2010 and working on a publishing page.In my page am using SharePointWebControls:InputFormTextBox as my Header for content area.Currently am hardcoding the text what i want to show.Now i have to provide  the option to end user to change the text.this is the code am using. <PublishingWebControls:EditModePanel runat="server" CssClass="edit-mode-panel" PageDisplayMode="Display">              <span>Message Details</span>                        </PublishingWebControls:EditModePanel>             <PublishingWebControls:EditModePanel runat="server" CssClass="edit-mode-panel">                          <SharePointWebControls:InputFormTextBox ID="TitleTextBox" runat="server" Text="Message Details"   />            </PublishingWebControls:EditModePanel> Now i have to get the value dynamically like this for my SharePointWebControls:InputFormTextBox fi

Changes in the values of controls of .cs file not reflecting on .aspx webpage while execution.

In my code I am assigning certain values to labels from data reader.While debugging I can see that proper values are assigned but the changes are not reflecting in the end of debug on the webpage that are executing.// My Code// Question.aspx.csusing System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;public partial class Examinee_Question : System.Web.UI.Page{    ExamFunctions ef = new ExamFunctions();    SqlConnection con,con1;    SqlCommand cmd,cmd1;    SqlDataReader dr,dr1;    String QType="";    int ctr = 1;    protected void Page_Init(object sender, EventArgs e)    {        con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Db.mdf;Integrated Security=True;User Instance=True");        con.Open();        con1 = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Db.mdf;Integrated Security=True;User Instance=True&qu

Pass values between user controls on 2 different aspx pages

I have 2 user controls that is hosted by 2 different aspx pages.example: srcpage.aspx --> hosts the --> sourceusercontrol.ascxanddestpage.aspx --> hosts the --> destinationusercontrol.ascxI would like the values in the text fields of the sourceusercontrol.ascx to be passed on to the labels in the destinationusercontrol.ascx. I have gone through the MSDN ASP.Net examples and i was able to successfully pass values between two aspx page using the postback URL functionality, but cannot do the same thing with the usercontrols on 2 different aspx pages. Any suggestions would be helpfull....! Thanks..! 

How to get the values of controls placed inside the repeater

Hi friends.........         In my code i will get the controls dynamically according to the Family members count.Now i need to display the values of each control individually which are placed inside the repeater control.  plz plz go through my code then you can understand my situation.I want to get the values of txtMemberName,drpRelationship,txtDateofBirth as in my database(dataset) for each control.This is my code:.aspx page<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="familyDetails.aspx.cs" Inherits="UI.familyDetails" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">    <title>Untitled Page</title></head><body>    <form id="form1" runat="server">    <div>    <asp:Button ID="btnGetFamilydetails" runat="server" Text="Family Details"             onclick="btnGetFamilydetails_Click" />          <asp:Repeater ID="repFamilyDetai

How to override the style values in a sharepoint workflow task form


I've created a aspx task form, and it's working as planned.  However, the window that is popping up when the task form fires is too small, and I would like to set the initial height/width to my own values.  How do I override the standard sharepoint css/style values so that I can control the size of the task window?


Rocky Sanders

Validating form values before insert


Before committing the record from the postback of the Create or Edit method in my controller, I validate the values in the form against some business rules in the GetRuleViloations() of this domain object.  The following rule example is written in two ways.  The 1st one validates against the numeric values in form, the 2nd one validates using the associated object (lookup table in database) description via the foreign key.  I would like to use the 2nd method, but during the Create postback the associated object is always null.  

/***** this works for Edit postback but doesn't work for Create postback *****/
if (Reason.HasValue && (Status.HasValue && Status1.Status1.Contains("TBD"

On GridView Click, populate other controls with column values


Hello team,

I have 5 controls on the page - textbox, radiobutton, listbox, checkbox, and any other one more. And i have a grid. The grid has 5 corresponding columns. I have to make the grid row clickable, and on the click, i have to populate my 5 controls with each of the corresponding grid column values.

Please let me know how can i make it. I know that i can make the grid clickable, by setting the e.row.attribute.add("OnClick", "javascript:return passValues();");. In this case, all the value passing will happen in javaScript. Is this the correct way? I have yet to try implementing this, not sure if there will be any issues.

Before that wanted to know if there is any other approach to achieve this. Please help!

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend