Question : Textbox add button click onBlur

Good afternoon,
Im trying out an idea that i read about on one of the forums about running code onBlur.

The idea is to have a button and in javascript click it onBlur, my issue is I cant find the button Ive created.

When I look at the HTML code generated, the name I have assigned has now become 'ctl00$MainContent$TextBox1_LostFocus'. From what I understand the ctl00 is regenerated everytime, so I thought I could use Page.GetUniqueIDRelativeTo, but doesnt seem to work, and generates the error- This control is not a descendent of the NamingContainer of 'TextBox1_LostFocus'.

Any ideas how I can reference the button TextBox1_LostFocus?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
TextBox1.Attributes.Add("onBlur", "document.getElementById('" & Page.GetUniqueIDRelativeTo(TextBox1_LostFocus) & "').click();")


ASPx Code:-
<%@ Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
    CodeBehind="Default.aspx.vb" Inherits="WebApplication1._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
                <asp:TextBox ID="TextBox1" runat="server" ></asp:TextBox>
                    <asp:Button ID="TextBox1_LostFocus" runat="server" Text="Button" />
                    <asp:Button ID="TextBox1_GotFocus" runat="server" Text="Button" />

                <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        </ContentTemplate>
        <Triggers>

        </Triggers>
    </asp:UpdatePanel>



            <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <div id="divTest" runat="server">
                       Nothing yet
                    </div>
                    <asp:Timer ID="Timer1" runat="server" Interval="300">
                    </asp:Timer>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="Textbox1" EventName="TextChanged" /> 
                </Triggers>
            </asp:UpdatePanel>
</asp:Content>

Answer : Textbox add button click onBlur

Aaron Blood wrote an excellent general purpose find routine ("Kickbutt Find") at http://www.xl-logic.com/modules.php?name=Downloads&d_op=getit&lid=228   You may have to register for this site to get to that link.

I added a macro to call that find routine to search all sheets for text that you specify in formulas. It will then select all such cells. As you go from worksheet to worksheet, you can then review those selections.

If you were looking for formulas that reference a named range like frrr_isis, just enter that text in response to the input box.

Brad
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
Sub SearchAllSheets()
Dim ws As Worksheet
Dim rg As Range
Dim FindText As String
FindText = Application.InputBox("Please enter the address or named range you want to find")
For Each ws In ActiveWorkbook.Worksheets
    Set rg = Nothing
    Set rg = Find_Range(FindText, ws.Cells, xlFormulas, xlPart, False)
    If Not rg Is Nothing Then
        ws.Activate
        rg.Select
    End If
Next
End Sub

'Find_Range written by Aaron Blood
Function Find_Range(Find_Item As Variant, _
    Search_Range As Range, _
    Optional LookIn As XlFindLookIn = xlValues, _
    Optional LookAt As XlLookAt = xlPart, _
    Optional MatchCase As Boolean = False) As Range
     
    Dim c As Range, FirstAddress As String
     
    With Search_Range
        Set c = .Find( _
            What:=Find_Item, _
            LookIn:=LookIn, _
            LookAt:=LookAt, _
            SearchOrder:=xlByRows, _
            SearchDirection:=xlNext, _
            MatchCase:=MatchCase, _
            SearchFormat:=False) 'Delete this term for XL2000 and earlier
        If Not c Is Nothing Then
            Set Find_Range = c
            FirstAddress = c.Address
            Do
                Set Find_Range = Union(Find_Range, c)
                Set c = .FindNext(c)
            Loop While Not c Is Nothing And c.Address <> FirstAddress
        End If
    End With
     
End Function
Random Solutions  
 
programming4us programming4us