.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

Trying to validate a textbox not working

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :ASP.Net

I have a bunch of validation on my page and I have a summarygroup attached which works fine. I have a drop down that when "other" is chosen will place a textbox for the user to enter in information. I need to make this "other textbox" required. I added a custom validator however it never seems to fire?  Can someone give me some insite as to why just this one validation does not fire ?


<%@ Page Title="" Language="C#" MasterPageFile="~/SBSBRightBar.Master" AutoEventWireup="true"
    CodeBehind="Profile.aspx.cs" Inherits="SBSB.Profile" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<asp:Content ID="Content2" ContentPlaceHolderID="Body" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <asp:Panel ID="Panel1" runat="server">
                <asp:MultiView ID="mvTopText" runat="server">
                    <asp:View ID="vwJoin" runat="server">
                        <asp:Panel ID="pnJoin" runat="server">

View Complete Post

More Related Resource Links

SqlDataSource ControlParameter textBox:Not Working

I have a stored procedure that returns 3 searches1) ALL records2) Records staring with something3) Records containing somethingThe stored Proc works finehere is the proc header:CREATE PROCEDURE [dbo].[procGetOHLCSymbolReferenceQuick](@SearchContains VARCHAR(20)='X1234',@SearchStartsWith VARCHAR(20)='X1234')THE ISSUEI have a gridview on a user control, with two texboxes. The gridview is supplied by a SQLDataSource. The textboxes provide that Users Filter demands. The TEXT BOXES<asp:TextBox ID="txtNameStartsWith" runat="server" Width="75px" TextMode="SingleLine"  BackColor="#FFF6CD" /><ajaxtoolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="txtNameStartsWith" FilterType="LowercaseLetters,UppercaseLetters,Numbers,Custom"  ValidChars=" @$.^!" /><asp:TextBox ID="txtNameContains" runat="server" Width="75px" TextMode="SingleLine"  BackColor="#FFF6CD" /><ajaxtoolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server" TargetControlID="txtNameContains" FilterType="LowercaseLetters,UppercaseLetters,Numbers,Custom"  ValidChars=" @$.^!" />THE SQLPARAMETERS<SelectParameters&g

TextBox AutoPostBack not working when handling other DHTML event


I have to format a number in a TextBox while it is being typed. Right after the TextBox looses focus, I need to do other processing on server side, including some database queries.

I'm doing the formatting by handling the onkeyup event, client side. But when I add the handler, the onTextChanged event stops firing on the server. I've tried different return values for the handler but unfortunatelly I'm stuck.

To reproduce the problem, here is a sample where the formatting function was replaced by a simple "convert to uppercase" function. You'll see that, contrary to the expected, the Label doesn't get filled when the TextBox looses focus. It does get filled, however, if the user presses the ENTER key.

What can I possibly be doing wrong with such a simple task?


<%@ Page Language="VB" %>

<script language="VB" runat="server">

Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)

'' Adding the event handler like this has the same effect as adding it inline

'txtTextBox.Attributes.Add("onkeyup", "return(upperCase(this));")

End Sub

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

lblTextBox.Text = S

RequiredFieldValidator not working for TextBox?


Hi there,

I've recently finished building one of my first websites (and CMS) in ASP.NET but have came across a problem where a RequiredFieldValidator isn't working as it should do? I originally created the admin page to not require the RequiredFieldValidator, but now that I do need it the page won't acknowledge it's there. I have even set the field in the database to not accept nulls, but the query will still insert a null value into the database (SQL Server 2008 Express).

Hopefully someone can tell me what I'm doing wrong! The TextBox that I'm referring to is "txtSectionTitle"

Thanks :)

<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Register TagPrefix="ThePines" TagName="Navigation" Src="includes/navigation.ascx" %>
<%@ Register TagPrefix="ThePines" TagName="AdminNavigation" Src="includes/adminNavigation.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml">

<title>Add New Section - <%= ConfigurationManager.AppSettings["Web_Name"] %></title>
<meta http-equiv="Content-Type&quo

textchange event not working from textbox on formview


Hello guys.  I have a formview which in insertmode is required to assign a value to a textbox from another on textchange event.  I can't get it working.

here's formview code (in bold:  event call:

<asp:FormView ID="fvPrecios" runat="server" AllowPaging="True" DataSourceID="OdsPrecios"
        Style="position: relative" CellPadding="4" ForeColor="#333333"
        DataKeyNames="precnume" >
            <table style="position: relative" width="400">
                    <td style="width: 62px; height: 26px">
                        <asp:Label ID="lblEditNombre" runat="server" Text

How to validate a GridView textbox in edit mode


I am working with VWD Express and Visual Basic. Please take this into consideration if you are willing to answer my question.

I do have the following code for a GridView.

        PageSize="100"  >

textbox in the form but text_changed not working correctly



I got a textbox in my form and I want to when a user start typing in the textbox the listbox below the textbox will select the item that starts with that string

for example, it i type I

than in myserver side code will call that SearchString method which will go through that listbox and do the rest...

protected void CountryTxt_TextChanged(object sender, EventArgs e)
        string s = CountryTxt.Text;

the problem is it only stops in the textchanged after I press the enter key; it doesn't seem to work just by typing the characters in the textbox...

<asp:TextBox ID="MachineTxt"
         runat="server" Width="42px"
         ontextchanged="CountryTxt_TextChanged" AutoPostBack="True"> </asp:TextBox>

Can someone give me some indications whether I'm doing something wrong ?



Dynamic TextBox Validation not working on dynamic DataGrid on PlaceHolder



I have a placeholder to which I programmatically add DataGrids... In the DataGrids, I programmatically add TextBoxes along with dynamic validations. Somehow, the DataGrids show up, but the dynamic validations don't work. If I set them to static, the blank space for them appears, but still, they wont work.

I'd appreciate your help on this.



Dynamic Filling of TextBox AutoComplete not working


Hi guys,


i would like to fill the textbox autocomplete stringcollection "on the fly" while typing. i don't want to fill the collection while initializing, 'cause it's too much data: the sql server-table has about 100.000+ rows. the filling takes too much time and the "autocomplete-popup-find-something-box" itself is getting too slow, too.

my configuration:
.NET-Framework: 2.0.50727, System.Windows.Forms.TextBox

TextBox-Properties: AutoCompleteSource: CustomSource; AutoCompleteMode: Suggest

i tried several different things...

1. i did put this code in the "TextChanged"-event, but i think it's 'too late' there:

private void

TextBox style="border:none" is not working :(


Hi everyone,

I have a ASP.NET form which have several textboxs.

I wanted to show this as non-edit mode (just displaying)

So I did :

<b>  Phone:</b>                 
                <asp:TextBox ID="TextBoxPhone" style="border:none; width:150px" runat="server">

All to my textboxs.

The problem is, it does not show in my Internet Explorer 7 browser,

but the box shows and someone could edit in Internet Explorer 8 browsers.  :(

How could I fix this? oh I have something in my 'html' tag which is:

<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=7" />




I would appreciate any help!!! Laughing

javascript textbox clear not working



i have javascript to clear the textbox but its not working and js called asshipping.js

below the code i have in asshipping

function clear() {
function clearfields() {
    O('TextBox1').value = '';
    O("TextBox2").value = '';
    O('TextBox3').value = '';

function O(id)
  return document.getElementById(id);

default.aspx page

<!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>

   <script src="Script1/asshipping.js" type="text/javascript"></script>
<body  >
    <form id="form1" runat="server"  >

        <asp:Button ID="Button1" runat=&q

Firefox and google chrome textbox wrap is not working


Hi there, i have did some research on this topic. But what i have try to search still cannot solve my problem in Firefox.

 I have a textbox with textmode= multiline. i put a wrap= true is becoz i wan to display the address line by line and same as how the users input. I have tested in IE,Google Chrome and Firefox, two browser is not working except the IE.


<asp:TextBox ID="txtContactAddress" runat="server" CssClass="txtbox"

AutoComplete textbox and combobox not working


I am using a textbox and when I provide custom source from collection at design time it works but when i use custom source in code and fill data from a datatable it doesnot works.

Here is the code ...


 Dim dt As New DataTable
        dt = DataClass.getList("select cust_name from Customer").Table

        Dim cs As New AutoCompleteStringCollection
        For Each r As DataRow In dt.Rows

        TextBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend
        TextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
        TextBox1.AutoCompleteCustomSource = cs




validating is not working when I put HTML.TextBox instead of HTML.TextBoxFor


hi guys,

I have a comment form inside the blog posts. in the form, if the user is authenticated, I will assign the values of the user into textboxes. that part is as follows;

        @if (!User.Identity.IsAuthenticated) {
            <td class="td-field-name">@Html.LabelFor(model => model.Comment.CoommenterName)</td>
            <td class="td-field-separator">:</td>
            <td class="td-field">@Html.TextBoxFor(model => model.Comment.CoommenterName, new { @class = "input-text-1" })</td>
            <td class="td-field-name">@Html.LabelFor(model => model.Comment.CommenterEmail)</td>
            <td class="td-field-separator">:</td>
            <td class="td-field">@Html.TextBoxFor(model => model.Comment.CommenterEmail, new { @class = "input-text-1" })</td>
            <td><span class="font-9px italic">will not be displayed ! (but will show your <a href="http://gravatar.com">Gravatar</a>)</span></td>
        } else {

            <td class="

Working with SharePoint document libraries

Document libraries are collections of files that you can share with team members on a Web based on Microsoft Windows SharePoint Services. For example, you can create a library of common documents for a project, and team members can use their Web browsers to find the files, read them, and make comments. Users with Microsoft Office 2003 can check out and edit the files as if they resided on a local or network drive.

By default, your team Web site comes with a built-in document library named Shared Documents, which is listed on the Quick Launch bar as well as on the Documents and Lists page.

Textbox Editable GridView in ASP.NET

This article describes how I made a fully editable gridview in C# using ASP.NET 2. The idea is that the GridView looks and works like an Excel spreadsheet. You see all the cells in the table, and you can edit any of the cells you like, and they are automatically updated (i.e. saved to the database). This is very often how people expect data tables to work in web pages, and I've often seen people clicking in vain on un-editable gridview cells, somehow expecting to edit them, and not understanding that they need to click an Edit button at the end of the row.

Highlighting Rows with TextBox OnFocus

In another article I explained that how you can make the rows of the GridView control clickable and highlight them when they are clicked. In this article I will explain that how you can highlight the GridView rows when you focus on the TextBox which is contained inside the GridView control.

Custom Editing Behavior for DataGridView TextBox Columns

For various reasons I'm using a DataGridView instead of a ListView, and while configuring the DataGridView to look like a ListView wasn't much of a problem, there's one thing that got on my nerves, which is the behavior of textbox cells in edit mode: It is much too easy to leave the edit mode accidentally, simply by pressing the cursor keys at the wrong time. For example when the text caret is positioned behind the last character of the textbox cell content, and you press the right arrow key
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