Wednesday, 2 October 2013

Enable/Disable Autocomplete to Textbox in C# or VB.NET

Hi friends,in this article i will explain about How to Enable/Disable Autocomplete to Textbox in C# or VB.NET.
We see in many sites when you double click on textbox then the previously entered names or data will appear.If we want to remove that appear of data that situation we refer this.
In previous articles i already explained about Validation in MVC 4 Razor with the Data Annotation Validators in “MODEL” , Bind,Save,Edit,Update,Cancel,Delete,Paging example in GridView in ASP.NET using VB.NET,How to insert multiple rows into the GridView without using any database in ASP.NET using VB.NET/C# || how to save multiple rows in GridView into a Session.

Take one ASP.NET web page and write the following code.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button" />
    </div>
    </form>
</body>
</html>

 
and write the below code in the C# code .
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class AutoComplete : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        txtUserName.Attributes.Add("autocomplete", "off");
    }
}


In  VB.NET:

Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Partial Public Class AutoComplete
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        txtUserName.Attributes.Add("autocomplete", "off")
    End Sub
End Class


and Run the application .The textbox is never show the already given entries.

No comments:

Post a Comment

© 2012-2018 Aspdotnet-Kishore.blogspot.com. All Rights Reserved.
The content is copyrighted to Kishore and may not be reproduced on other websites without permission from the owner.