.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

codebehind set focus textbox field in ajaxtoolkit : Tab

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

Hi all ,

I am stuck in the set focus field in field in ajaxtoolkit : Tab  at codebehind when button click.

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

    If StringUtil.IsStringEmpty(Me.ddlSex.SelectedValue) = True Then

       Page.ClientScript.RegisterStartupScript(Me.GetType, "ErrMsg", 
            JScriptUtil.ErrorMsg("Jantina (Sex): "

    End if

   End Sub

View Complete Post

More Related Resource Links

How to take value of bound field of grid in a variable or in a textbox.


How to take value of bound field of grid in a variable or in a textbox.

 I m using this code in .aspx page for grid.

<asp:GridView ID="Grd_Mprocess" runat="server" AutoGenerateColumns="False"

                      Width="100%" AllowPaging="True"


                      AllowSorting="True" PageSize="5"  >

                 <RowStyle CssClass="odd" />


<asp:BoundField HeaderText="DOC_TYPE_PK" DataField="DOC_TYPE_PK"  Visible="true" >


  <asp:TemplateField HeaderText="DOC TYPE ID" Visible="true">  &nbs

gridview filtering using a codebehind (textbox + search button)

i am trying to replicate the following sequence: input text into text box > press search button > search a database using LIKE operator > display using a gridview or listview. this sequence is fairly easy to do using the drag and drop then sqldatasource options, but i am trying to do the same result using a codebehind.  here is my code:   ____________________________________________________________________________________________________________ SqlConnection myConn; myConn = new SqlConnection(@"Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\projectDB.mdf; Integrated Security=True;User Instance=True"); myConn.Open(); string strSQL; strSQL = "SELECT * FROM Message";       //strSQL = "SELECT * FROM Message WHERE Message LIKE '" + txtSearch.Text + "'"; SqlDataAdapter da = new SqlDataAdapter(strSQL, myConn); DataSet ds = new DataSet(); da.Fill(ds, "Message"); GridView1.DataSource = ds; GridView1.DataBind(); myConn.Close(); _____________________________________________________________________________________________________________  now, if I use this code inside a page_load event, it does work. if I put it inside a button_click event i get nothing. i am mystified by this.. any help? why can't i use a button to display my gridview1 when i'm using a code behind.  

How come I can't set focus to a textbox in DetailsView?

Here's the first part of a DetailsView control definition:          <asp:DetailsView ID="DetailsView1" runat="server" DefaultMode="Edit" AutoGenerateRows="False" Width="100%" BorderColor="Silver">            <RowStyle Height="25px" />            <Fields>              <asp:TemplateField HeaderText="Name" SortExpression="Name">                <EditItemTemplate>                  <asp:TextBox ID="textBoxName" runat="server" Text='<%# Bind("Name") %>' CssClass="detailsTextBox" onclick="SelectText2(this)" onKeyUp="EnableSubmit()" />                </EditItemTemplate>                <InsertItemTemplate>        &nb

javascript for field validation on a textbox...

I'm looking at doing the validation for the email in javascript since we have asp.net 1.1. I can get it to just alert fine, but once I add the return validation it doesn't fire. Me.ImageButton2.Attributes.Add("onclick", "return validation(this);") <script language="JavaScript"> <!-- function validation () { var test=""; test = document.ticketForm.emailAddress.value; if (test == "xyz") { alert(test); return false; // validation failed } --> </script>

why isnt the focus being set to a textbox in the gridview?

Hi, i have a gridview with textboxes in. a barcode reader is used to enter data in the textboxes in the grid. when something is scanned in the page does a full postback. so after a postback and after something has been scanned in, i want the focus to be moved to the next textbox in the row inside the gridview.  i have some code, but it doesnt seem to work. after the postback the focus is set to one of the textboxes outside the grid. i need it to recognise one of the textboxes in the grid. i have tried to use the findcontrol property to do this still doesnt work. please can anyone see where i am going wrong. what i wanted to do is for it to automatically tab to the next textbs in the gridview after a postback. please any advise on this would be much appreciated. thank you very muchprotected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { WebControl wcICausedPostBack = (WebControl)GetControlThatCausedPostBack(sender as Page); int indx = wcICausedPostBack.TabIndex; var ctrl = from control in wcICausedPostBack.Parent.Controls.OfType<WebControl>() where control.TabIndex > indx select control; ctrl.DefaultIfEmpty(wcICausedPostBack).First().Focus(); } } protected Control GetControlThatCausedPostBack(Page page)

textbox focus problem


I have a textbox (txtMaiden) and a radio button list (rblGender) in two separate User Controls that I'm using for a registration site. The txtMaiden control appears or disappears depending on whether Male or Female is designated on the radio button. This all works fine but I want the textbox to have focus when it becomes visible. As of now, it only gets focus when the page refreshes. Code follows. Any ideas?

<Prf:gender ID="GenderE" Gender='<%#Bind("Gender")%>' runat="server" />
<Prf:maiden ID="MaidenE" Maiden='<%#Bind("MaidenName")%>' Maiden_Disp='<%#Bind("MaidenName_Disp")%>'
    runat="server" />

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="gender.ascx.vb" Inherits="userControls_profile_gender" %>
<asp:Panel ID="pnlGender" Visible="true" runat="server">
    <div class="label">
        <asp:Label ID="lblGender" Text="Sex:" runat="server" />
    <div class="ctrl">
                <asp:RadioButtonList ID="rblGender" AppendDataBoundItems="True" AutoPostBack="True"

Programmatically creating a Person or Group type field Textbox (similar to 'Assigned To' field in Ta


In our ASP.NET application created with SharePoint object model, we have a user interface with a Contact Person TextBox, we want this TextBox to be similar to the “Assigned To” filed in out-of-the-box Task List where you can search for a particular site user by typing in his/her name. How can we achieve this functionality programmatically?

Thanks in advance………

Time added to Detailsview TextBox Date only field


Does anyone know why a time stamp is added to a textbox field that is bound to a SQL 2008 date datatype field?

I can view the data in the database and, as expected, it only contains a date. When I bind the textbox to the db field it tacks the time '12:00:00 AM' to the end of the date?


keep focus on textbox on textchange event



How can I keep focus on caller textbox on textchange event or set focus on a given textbox according to a given value?

How can I know which textbox triggered the event if I need to use the same textchange method?

thanks in advance

Silverlight - Textbox on focus wait till a Asynchronous process is complete



I have a textbox, where i call its lostfocus event when the value changes.

In lost focus i do a Asynchronous process to update a grid with the text entered. 

I have a scenario in which immediately after changing the value in textbox i hit a button, though the button click event raises i want it to wait till the asysnchronous process in lost focus of the textbox is complete. i want to do this as i use the result from lostfocus in button click event.

Please let mt know if there is a way to make the lost focus wait till it completes the asynchronous call.



How to prevent Loss of Focus if there is Validation error on a textBox?

Hi i have a TextBox displayed as a TreeViewItem and when the user enters text and Tabs away or clicks somewhere else i want the control to retain focus if there is any validation error.Is there anyway i can do that? I am adding the ValidationRule to the TextBox created dynamically in code..I do see the default redborder when there is a validation error.I just want to force the user to correct the error and not go anywhere else in the app until its fixed..
Thanks in advance...

MaskedEditExtender, text removed if you lose focus and set focus back on textbox


I have a MaskedEditExtender with Mask="(999) 999-9999".

Now my problem is, if someone goes into the textbox and enters


Then they leave the textbox, and then see that they forgot to enter the area code, if they go back in there to enter the area code, it starts overwritting the other numbers instead of just adding to them. 

How to set focus to UserName textbox in Login Control ?



can you please tell how to focus cursor to UserName TextBox in Login control when page is loaded for the first time in browser ? 

setting focus to a textbox


using vb.net/asp.net 2005

after the user clicks on a button in the buttonClick event I am trying to set the focus at the end of the function simply as follows:


However the focus is instead going to another button.  The tabIndex property is not set on any controls on the page.  Has anyone experience this?  thanks


Set Focus on Textbox


    I have a composite control with Listbox and a Textbox. I am trying to achieve a functionality where in if I type something in the text box, the list box items gets filtered based on the text typed.

   I am able to get this working, however I am having issues in retaining the Keyboard focus in the Textbox.

   I am doing this functionality on the Key Up Event of the Textbox. If I type a text the event handler is getting triggered and performing the operation, but the focus goes from the Textbox

I am forcing the Focus by calling the Focus() function on the Textbox, but it doesn't seem to be working.

 SDK of Focus function says: "Even if an element is focusable and enabled, event handling within a specific tree, (such as for a composite control) might respond to the preview focus events by not allowing focus there, thus this method would return false."

How can I force the focus on the Textbox object.


Retrieve a hidden flag/field/ textbox/ variable from SSRS in C# with reportExecutionService



I want to set a HIDDEN flag in my reports (SSRS 2008) and retrieve in my C# code. If it's possible please share your suggestions.


Thank you,


How to empty a textbox in detailsview codebehind



I have a detailsview with three textboxes as itemtemplates. Each for holding a different date. To avoid the option of users entering invalid values the textboxes are disabled and the user can use a calender control to fill the dates. Because the textboxes are disabled I added a linkbutton to empty a date, if the user decides to clear it.


<asp:detailsview id="detailsview1" runat="server" height="50px" width="550px" CellPadding="2" 
                         datakeynames="ZavPogodbaID" datasourceid="SqlDataSource1" 
                         fieldheaderstyle-width="115px" autogeneraterows="false" DefaultMode="Insert" 
            <FieldHeaderStyle Width="150px" />
                <asp:TemplateField HeaderText="Stranka:" ControlStyle-Width="400px" ControlStyle-Font-Bold="true" >
                        <asp:DropDownList ID="ddlStranka&q
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