.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

requiredfieldvalidator and AutoPostBack howto

Posted By:      Posted Date: September 14, 2010    Points: 0   Category :ASP.Net
Fairly new to ASP NET. I have 3 text boxes all with AutoPostBack set , in the example below the textchange events don't do anything although in reality they will. I have required field validators on each. All text boxes are initially blank. I would have assumed that if I tab out the first text box without entering something I would get an error message but not so. If I enter something tab out and back in and delete the text then I get either With CausesValidation="False" a message that flashes and disappears With CausesValidation="True"  I get all the error messages. Is it possible to get required field messages only for the textbox you have just left empty. I have spent quite a long time on this to no avail. Thanks Jim<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site1.Master" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication11.WebForm1" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <asp:ToolkitScriptManager

View Complete Post

More Related Resource Links

SharePoint Wiki HowTo Template



was wondering if anyone has or has suggestion on the following:

we are contemplating creating a wiki type howto for our users which needs to be categoriesed into permission level (eg user, super user, admin).

We would quite like to have the ability to add content, and then link the relevent catories to it (done via a lookup at moment).

And relevent video (e.g embeded you tube).


The video part I am thinking of a library with a field type that allows embed (do you know of any?).  On the wiki page I quite like it if the video would show rather an having to navigate to them, but doubt this is possible.


I know wiki can't have a uniformed template due to the way they are produced and web parts have to be added manually.  Does this mean are idea would maybe be better as a publishing site with a custom template?

RequiredFieldValidator minimum 6 number

Hi,This my code:<asp:RequiredFieldValidator ID="RequiredFieldValidator2" ValidationExpression="^[a-zA-Z0-9]{6,}$" runat="server" ControlToValidate="CreditCardNumber"  ErrorMessage="Stevilka kreditne kartice, ki ste jo vnesli, ni veljavna!"                 ValidationGroup="ErrormessageValidationGroup">!!!!!!</asp:RequiredFieldValidator>ValidationExpression not works! The condition must be at least 6 numbers before it is implemented.thanks

HOWTO add a C#.NET library to SQL Server as an assembly that uses such references as system.web.

HOWTO add a C#.NET library to SQL Server as an assembly that uses such references as system.web. I have a C# library (dll) I want to add to SQL Server via "CREATE ASSEMBLY", but the DLL uses these references: Microsoft.VisualBasic System System.Core System.Data System.Data.DataSetExtensions System.Drawing System.Management System.Web System.Web.Extensions System.Web.Mobile System.Web.Services System.Xml System.Xml.Linq And just to be clear, the DLL is a .NET 3.5 app, with the SQL Server being SQL Server 2008. Right off the bat, the "CREATE ASSEMBLY" call fails due to System.Web, which strangely, is The CREATE ASSEMBLE says this error: Msg 10301, Level 16, State 1, Line 1 Assembly 'MyLibrary' references assembly 'system.web, version=, culture=neutral, publickeytoken=b03f5f7f11d50a3a.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: 2(The system cannot find the file specified.)). Please load the referenced assembly into the current database and retry your request. I have tried to use VS 2010, to create a SQL Server DB project, and it point blank does not let one add references to things like System.Web. When trying to use "Add Ref", VS 2010 literally lo

DropDownLists and AutoPostBack

Hi,I have a web form with a number of DropDownLists on. The selection in each determines what data is displayed in the other lists, all of which data comes from a SQL server table. I've noticed that when I set AutoPostBack to true, the whole page refreshes when changing the selection within each list and I've also noticed that the values selected in the other lists are lost.Is there anyway which I can:1) Maintain values already selected across postbacks2) Stop the page refreshing each time a new item is selectedThanks in advance,Kev

AutoPostback in Repeater in UpdatePanel is refreshing the page

Here's quite a weird problem:I've got a TextBox with AutoPostBack="true" and OnTextChanged property set.The textbox is located inside a Repeater, which in turn is located inside an UpdatePanel.Problem is - whenever the TextBox postsback, the whole page gets reloaded, instead of the UpdatePanel only.Here's how the thing looks:<asp:UpdatePanel runat="server"> <ContentTemplate> <asp:Repeater ID="itemsRepeater" runat="server"> <HeaderTemplate> <ul class="lstProducts"> </HeaderTemplate> <ItemTemplate> <li> <asp:TextBox AutoPostBack="true" OnTextChanged="whatever_Click" runat="server" /> </li> </ItemTemplate> <FooterTemplate> </ul> </FooterTemplate> </asp:Repeater> </div> </ContentTemplate> </asp:UpdatePanel> Interesting thing is, if I take the TextBox out of the repeater, it refreshes only the UpdatePanel.So is if I put a Button inside the repeater - only the UpdatePanel gets refreshed.But whenver I place an AutoPostBack-ing control inside the Repeater, the whole page gets refreshed.Any help would be welcomed,Thanks<asp:UpdatePanel runat="server">             &

Using Update Panel on a repeater using Dropdown Autopostback

 Hi, The subject is explanatory, but here are some details:   I want to update a repeater when SelectedIndex value changes for a dropdown list. The problem is Nothing happens. My aspx page is present in a nested master page. and neither autopostback works nor update panel. i have set the AsyncPostBack trigger on SelectedIndexChange event.   Please let me know what am i doing wrong or what am i missing. PS: I have never worked on ajax before so I might have overlooked something.

How do I use a inside a field in my GridView?

hi all, I am trying to add RequiredFieldValidator in some of my fields when my GridView is in "EDIT mode".How do I do that? This is what I use inside a table cell on my FormView:<td> <asp:RequiredFieldValidator ID="SettingID_RFV" runat="server" Display="dynamic" ControlToValidate="txtbox1" ErrorMessage="ID is required" SetFocusOnError="True" ValidationGroup="ItemInsertItemTemplateVG"/>* </td> How do I add this inside the fields of my GridView?? Thank you      

Howto set the value of webgridcolumn.format in the class file?

About:  I want to define format string of the webgridcolumn by myself.Example:There is a ID column in a webgrid ,i want the cell of this column filled the data like "<a href="/Default/@ID">@ID</a>"Code: Microsoft.WebPages.Helpers.WebGrid mygrid = new Microsoft.WebPages.Helpers.WebGrid(tarobjs,canPage:Convert.ToBoolean(data.Groups["enablepager"].Value), rowsPerPage: Convert.ToInt32(data.Groups["pagesize"].Value));                 Microsoft.WebPages.Helpers.WebGridColumn[] columns = new Microsoft.WebPages.Helpers.WebGridColumn[data.Groups["col"].Captures.Count];                                 for (int i = 0; i < columns.Length; i++ )                 {                     columns[i] = mygrid.Column(columnName: data.Groups["col"].Captures[i].Value, header: data.Groups["headertitle"].Captures[i].Value);                                      }                 HtmlString myhtml = (HtmlString)mygrid.GetHtml(columns:colu

GridView EditTemplate DropDownLists' Loads fire before SelectedIndexChanged events on AutoPostBack=

My GridView allows EditTemplate but no DataSource in the aspx page. I set the DataSource & DataBind in code behind. My problem is with 2 of the 4 DropDownLists: they require AutoPostBack=true b/c the load of ddlDptmtGrid is dependant on the selection from ddlOrgGrid, and the load of ddlPosGrid is dependant on the selection from ddlDptmtGrid. The problem lies in that every postback calls each ddl's load & then the SelectedIndexChanged event, by this point the SelectedValue has been reset or wiped. And i can't use "if (!IsPostBack) { }" b/c the initial click of the lnkEditBtn is a postback & the DropDownLists don't even exist till in Edit Mode, so i need this initial load. But it appears on every postback all the controls in Edit mode are wiped & re-initialized, so it forces each DDL to be re-declared & re-loaded, but then the SelectedValue (which caused the postback) cannot be remembered?<asp:GridView ID="gridPendRoles" runat="server" CellPadding="5" AutoGenerateColumns="False" BackColor="#CCFFFF" BorderColor="Black" BorderStyle="Solid" onrowdeleting="gridPendRoles_RowDeleting" onrowediting="gridPendRoles_RowEditing" onrowcancelingedit="gridPendRoles_RowCancelingEdit" onrowupdating="gridPendRoles_RowUpdating"

disable autopostback of checkbox inside of GridView during SelectedIndexChanged of ListView

Hi, I hope my question is clear: I have a checkbox placed inside a gridview: <GridView><asp:TemplateField HeaderText="Driver">   <ItemTemplate>       <asp:CheckBox ID="CheckBoxDriver" AutoPostBack="true" OnCheckedChanged="GridView_Persons_SelectedIndexChanged" ValidationGroup='<%# Eval("ID") + "-" +((GridViewRow)Container).RowIndex %>' CssClass="CXDriver" runat="server" Checked='false' />   </ItemTemplate>       </GridView> For example: A listViewItem 1 has 3 drivers are checked, A listViewItem 2 has 2 drivers are checked. Therefore, if changing the selectedIndex of the list, the checkbox indexChanged event will be fired. How could I disable the autopostback of the checkbox during the listview item changed. Thanks in advance

Autopostback on the last list in a Cascading drop down list series

Hi,First off I'm very new to Ajax for .NET.  I have a Cascading drop down list that is working fine to load the correct lists however I would like to have the last one initiate a query and display a datagrid on the same page containing the results of the query.  Without Ajax involved this seems rather easy by using autopostback on the drop downs.  If I could do it through Ajax that would be great but I can settle with having the page to reload to display the data.  Right now I'm not sure how to do either.  I enabled autopostback on the last drop down and wrote a method for it but I get an error at runtime saying:Invalid postback or callback argument So I'm really not sure what to do to get this to work right.Any help would be appreciated.Thanks,-Jordan

LoginView, DropDownList, Cookie, AutoPostBack Conundrum

OK, I am at a complete loss. Users for my site can have many stores to configure under their one user account. When they login I have the app generate a cookie for each store and hold all the stores basic information. For each cookie I then generate a list item in a drop down list. I can get the list to generate just fine and all of the pages that reference the list get the information fine. When I change the list to a different item however, and the page posts back my first LoginView is set to LoggedInTemplate while my navigation loginview (in site.maser like the first one) and my content loginview (in the actual page) come back in AnonymousTemplate, even though the user is authenticated. I can either do a response.redirect or physically refresh the page and all loginviews are in LoggedInTemplate again. The problem is though that I lost all of the postback data so I can essentially only view information on the first item in the dropdownlist. Now, I am new to asp.net authentication, and while I feel that I am starting to get the hang of it, there is a very good chance that I am doing something wrong. I have all the authentication working correctly and except for this postback issue. I can login, navigate through pages that aren't accessible without being authenticated and I can logout without issue. If anyone has any suggestions it would be gr

Dropdownlist not firing SelectedIndexChanged on first item with autopostback true

Hi: Has anyone ever found a work around for the well documented and well known bug, the dropdownlist bug? Specifically where the SelectedIndexChange event does not fire on the first listitem, althought both autopostback and enableviewstate are true? In other words, if the first three items in the dropdownlist are red, blue, green, if you select green, the SelectedIndexChanged will fire, but if you then select red, the first item in the ddl, the event will not fire. All listitems will fire the SelectedIndexChanged event, except for the very first listitem. The HACK has always been to include a dummy item as the first list time like"Select a Color" to get around the first item bug. I have got a situation where I cannot use that hack. Ideas?  TIA, Bill  

validations for textboxs by using RequiredFieldValidator's and javascript

here i have 5 text boxs for 4 text boxs i kept RequiredFieldValidator's and for next text box i am return javascript function....   if am clicking on submit button only RequiredFieldValidator's are wrking bt java script function is not wrking....   how can i do this help me in this topic....  

Gridview, MasterPage, Ajax, AutoPostback and FRUSTRATION

I have a peice of code for a custom Gridview that works great if it is not in my Master.Page. As soon as I put it in my masterpage /ajax update panel it seems the autopostback function of my checkbox stops working.... please advice. Here is the relevent code :   NOTE: (I have tried to turn on ViewState in every thing I could think of.....still nothing) <asp:GridView ID="gvHR" CssClass="gridview" runat="server" AllowPaging="True" EnableViewState="true" DataKeyNames="HRID" AutoGenerateColumns="False" DataSourceID="ldsHR"> <Columns> <asp:BoundField DataField="FirstName" HeaderText="FirstName" ReadOnly="True" SortExpression="FirstName" /> <asp:BoundField DataField="LastName" HeaderText="LastName" ReadOnly="True" SortExpression="LastName" /> <asp:BoundField DataField="EmailName" HeaderText="EmailName" ReadOnly="True" SortExpression="EmailName" /> <asp:TemplateField HeaderText="LeftCompany" SortExpression="LeftCompany&quo

Weird behaviour of Gridview with textbox with autopostback OnTextChanged and AJAX CalendarExtender

I ran in to some strange behaviour of Gridview with textbox with autopostback OnTextChanged and AJAX CalendarExtender. This gridview is in an updatepanel with scriptmanager. When my gridview is filled with data, it keeps running my OnTextChanged  function and therefor makes my application terribly slow. I need to have the autopostback and ontextchanged function to recalculate stuff in my gridview. Does anybody know of this problem and if so does anybody found a workarround ?

autopostback problem in gridview why it show multiples times...


    <form id="form1" runat="server">
        <asp:DropDownList ID="DropDownList9" runat="server" DataSourceID="SC" DataTextField="ItemNo"
            DataValueField="ItemNo" Style=" left: 131px; position: absolute;
            top: 41px; z-index: 104;" OnSelectedIndexChanged="DropDownList9_SelectedIndexChanged" TabIndex="12" AutoPostBack="True" OnDataBound="DropDownList9_DataBound">
        <asp:GridView style="Z-INDEX: 101; LEFT: 14px; POSITION: absolute; TOP: 183px; width: 953px;" 
        id="Gridview1" runat="server" Height="127px" ForeColor="Teal" Font-Size="12pt" 
        Font-Names="Palatino Linotype" Font-Bold="True" Visible="False" 
        BorderColor="Transparent" OnRowDataBound="Gridview1_RowDataBound" 
        ShowFooter="True" SelectedIndex="5" OnRowCreated="Gridview1_RowCreated" 
        GridLines="None" CellSpacing="2" AutoGenerateColumns="False"><Columns>
<asp:BoundField DataField="RowNumber
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