| Author: Yousuf 23 Nov 2008 | Member Level: Silver | Rating:  Points: 6 |
Hi there
You can set the intial tab index by using the following code
Lets say i hava master page which has a button.
and i have a content page that has a 2 text boxes. Textbox1 has values nothing and Textbox2 has value = "Copy value to first text box and set focus" . when i click on button. my text box 2 value should be pasted with focus in the textbox 1
Note master page has and update panel
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Button ID="btnMasterPageButton" runat="server" Text="MasterPageButton" /> <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </ContentTemplate> </asp:UpdatePanel>
The code as follows ...
Code behind
Private Sub btn_UC_Main_button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_UC_Main_button.Click 'WANT TO WRITE CODE HERE ON CLICK SET FOCUS ON CONTENT'S (WEBFORM1.ASPX) PAGE TEXTBOX
Dim MyTxt As TextBox MyTxt = CType(Page.Master.FindControl("ContentPlaceHolder1").FindControl("TextBox2"), TextBox) CType(Page.Master.FindControl("ContentPlaceHolder1").FindControl("TextBox1"), TextBox).Text = MyTxt.Text CType(Page.Master.FindControl("ScriptManager1"), ScriptManager).SetFocus(MyTxt.ClientID) ' ''Me.ScriptManager1.SetFocus(MyTxt.ClientID)
End Sub
|