locked
how to find out which control is selected on a page in vb.net? RRS feed

  • Question

  • User2075848134 posted

    My student.aspx contains student data...labels,textboxes...etc controls. on clicking properties

    button popup page will show the properties of selected control.

    now "i want to find out which control is selected from that a page?"

    plz, help me.

     

    Friday, December 25, 2009 1:22 PM

Answers

  • User1006193418 posted

    My student.aspx contains student data...labels,textboxes...etc controls. on clicking properties

    button popup page will show the properties of selected control.

    now "i want to find out which control is selected from that a page?"

    Hi,

    I am not very clear what you are after. However, I worked out this demo based on my own understanding that the user can select any text in the page and when the user click on the button, a pop-up page tells what text the user selected just now.

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script type="text/javascript">
            function foo(e) {
                var h = document.getElementById("Hidden1");
                h.value = e.id;
            }
            function show() {
                var h = document.getElementById("Hidden1");
                alert("you selected " + h.value);
            }
        </script>
        
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            Text1: <input id="Text1" type="text"  onfocus="foo(this);"/><br />
            Text2: <input id="Text2" type="text"  onfocus="foo(this);"/><br />
            <input id="Button1" type="button" value="button" onclick="show();" />
            <input id="Hidden1" type="hidden" />
        </div>
        </form>
    </body>
    </html>

    If I am doing wrong, please feel free to let me know.

    Best Regards,
    Shengqing Yang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 30, 2009 2:17 AM

All replies

  • User-1811423900 posted

    You will need to use Javascripts onfocus or onchange event. 

    Saturday, December 26, 2009 12:02 AM
  • User-1032358594 posted

    Dim myControl1 As Control = FindControl("TextBoxId"

    FindControl Method (String)<!---->
    http://msdn.microsoft.com/en-us/library/486wc64h.aspx 

    This might get you started.

    Monday, December 28, 2009 12:47 PM
  • User1805528910 posted

    Hello Ash

    Could you please send little more information? your question is not clear ..!

    <input id="gwProxy" type="hidden"><!--Session data--><input onclick="jsCall();" id="jsProxy" type="hidden">

    Tuesday, December 29, 2009 6:11 AM
  • User1006193418 posted

    My student.aspx contains student data...labels,textboxes...etc controls. on clicking properties

    button popup page will show the properties of selected control.

    now "i want to find out which control is selected from that a page?"

    Hi,

    I am not very clear what you are after. However, I worked out this demo based on my own understanding that the user can select any text in the page and when the user click on the button, a pop-up page tells what text the user selected just now.

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script type="text/javascript">
            function foo(e) {
                var h = document.getElementById("Hidden1");
                h.value = e.id;
            }
            function show() {
                var h = document.getElementById("Hidden1");
                alert("you selected " + h.value);
            }
        </script>
        
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            Text1: <input id="Text1" type="text"  onfocus="foo(this);"/><br />
            Text2: <input id="Text2" type="text"  onfocus="foo(this);"/><br />
            <input id="Button1" type="button" value="button" onclick="show();" />
            <input id="Hidden1" type="hidden" />
        </div>
        </form>
    </body>
    </html>

    If I am doing wrong, please feel free to let me know.

    Best Regards,
    Shengqing Yang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 30, 2009 2:17 AM