Results 1 to 4 of 4

Thread: How to set the maxlength of the textboxes dynamically

  1. #1
    Join Date
    Jan 2009
    Posts
    113

    How to set the maxlength of the textboxes dynamically

    Hello friends,

    I want to set max lengths for my text boxes and all of them are dynamically.I have hard from my friends that it's possible but don't know how to do it can anyone help me out with this issue.


    Amd 9550
    Gigabyte 780 with Intel Chipset
    2gb ram
    300 gb HDD
    9600 gt 512

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: How to set the maxlength of the textboxes dynamically

    Try to use the following code i am sure it will work for you.

    HTML Code:
    function SetCVV2MaxLength(curNumber)
    {
          var objCtrl = document.getElementById('txtSomeControl');
          if(curNumber == 3 || curNumber == 4)
          {
                objCtrl.maxlength = 3;
          }
          else
          {
                objCtrl.maxlength = 4;
          }
    }

  3. #3
    Join Date
    Jan 2009
    Posts
    113

    Re: How to set the maxlength of the textboxes dynamically

    I have forgotten to mention above i want the code in Visaul Basic.

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    Re: How to set the maxlength of the textboxes dynamically

    Following are the code for Visual Basic.

    Over here we will assume that connection is opened

    HTML Code:
    public DataTable GetData(SqlConnection oConnection,string SqlQuery)
            {        
                SqlCommand oCommand;
                SqlDataAdapter oDataAdapter;
                DataTable dtData=null;
                oCommand = new SqlCommand(SqlQuery, oConnection);
                oDataAdapter = new SqlDataAdapter(oCommand);
    
    
    
                oDataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
                oDataAdapter.Fill(dtData);
                oDataAdapter.Dispose();
                oCommand.Dispose();
                return dtData;
            }
    
    private void SetMaxLengthText()
            {
                foreach (DataColumn dc in dtDatos.Columns)
                {
                    Control[] control;
                    control = this.Controls.Find(dc.ColumnName, true);
                    if (control.Length > 0)
                        ((TextBox)control[0]).MaxLength = dc.MaxLength;
                }
            }

Similar Threads

  1. Replies: 6
    Last Post: 10-07-2011, 11:13 AM
  2. How can I call VBA method dynamically?
    By opaper in forum Software Development
    Replies: 5
    Last Post: 28-01-2010, 09:25 AM
  3. Casting a table dynamically
    By Logan 2 in forum Software Development
    Replies: 5
    Last Post: 16-01-2010, 11:55 AM
  4. Dynamically Loading a C# DLL
    By Allan.d in forum Software Development
    Replies: 3
    Last Post: 23-11-2009, 07:54 AM
  5. Set maxlength property on multiline textbox in Asp.net
    By Miss Kelly in forum Software Development
    Replies: 2
    Last Post: 17-01-2009, 05:57 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,504,466.60590 seconds with 17 queries