Textbox Properties from VBScript

Discussion in 'ASP .Net Web Controls' started by Gary Nelson, Oct 29, 2003.

  1. Gary Nelson

    Gary Nelson Guest

    I am trying to get at the properties of a TextBox from VBScript on an
    ASP.NET page. In particular I'm trying to find the equivalent of the
    Textbox1.SelectedText property. Could anyone tell me what it is?

    Is there any place where you can find a list of equivalents between VB.Net
    and Script?

    So far I've found several like:

    LostFocus = OnBlur

    Count = Length

    and a few others, but every time I run into a new one it is very difficult
    to figure out the equilvalent.

    Also, when I stop the execution of a script running on a web page, from the
    Command window I can get at the properties of a control, but it won't list
    them all. I get the following message:

    < More... (The first 100 of 165 items were displayed.) >

    How can I get the rest of the items to display?

    Gary
     
    Gary Nelson, Oct 29, 2003
    #1
    1. Advertising

  2. Hi Gary,

    Thank you for posting to the MSDN Managed newsgroups. We are acknowledging
    your post and you should receive response from the community within 2
    business days of your post.

    If you have any concerns, please feel free to let us know.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ¨C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
     
    Jacob Yang [MSFT], Oct 30, 2003
    #2
    1. Advertising

  3. Hi Gary,

    Firstly I want to let you know that vbscript is a subset of the vb
    language. That is, many properties or methods from vb language may not be
    implemented in vbscript. In other words, there may be not one-to-one
    mapping between vb and vbscript. In addition, there is no mapping table
    between the two languages.

    As for the selectedText, in HTML, we can make use of the document.selection
    object, as well as capturing the MOUSEUP event to implement the same
    function as what the selectedText property in desktop application.

    For your reference, I copied the whole html below. (I am using JScript for
    the demonstrating.)

    ----------------------------
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>

    <SCRIPT LANGUAGE="JavaScript">

    <!-- Begin
    var text = "";
    function getActiveText(e) {

    // Sets text MSIE or Netscape active
    // text based on browser, puts text in form
    text = (document.all) ? document.selection.createRange().text :
    document.getSelection();

    document.theform.text.value = text;
    return true;
    }

    document.onmouseup = getActiveText;
    if (!document.all) document.captureEvents(Event.MOUSEUP);
    // End -->
    </script>
    </HEAD>

    <BODY>
    <center>
    <form name=theform>
    Highlight any text on the page and JavaScript will 'capture'<br>
    it in the textbox below. Internet Explorer also allows for <br>
    the capture of text highlighted within a textbox or textarea: <br>
    Here's two to try out:<br><br>

    <input type=text name=demo value="highlight me!"> or <textarea>or highlight
    me!</textarea>
    <br>
    <br>
    Selected text: <input type=text name=text value="">
    </form>
    </center>


    </BODY>
    </HTML>
    ---------------------------------------------------

    Does it answer your question? If I have misunderstood your concern, please
    feel free to let me know.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ¨C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
     
    Jacob Yang [MSFT], Oct 30, 2003
    #3
  4. Gary Nelson

    Gary Nelson Guest

    Jacob,

    Thanks for the help!

    I was able to get your code working and it is along the line of what I want
    to do, but I have just one problem.

    Since I'm doing my script in VBScript I need to be able to do one of two
    things:

    Convert the lines:

    text = (document.all) ? document.selection.createRange().text :
    document.getSelection();

    to VBScript. Or call the getActiveText function from VBScript and get the
    value of the selected text back.

    I don't know Java script, so I can't figure out what the ? means on the
    line. And I tried calling the getActiveText function, but my VBScript
    doesn't seem to see it.

    Thanks again,


    Gary




    "Jacob Yang [MSFT]" <> wrote in message
    news:...
    > Hi Gary,
    >
    > Firstly I want to let you know that vbscript is a subset of the vb
    > language. That is, many properties or methods from vb language may not be
    > implemented in vbscript. In other words, there may be not one-to-one
    > mapping between vb and vbscript. In addition, there is no mapping table
    > between the two languages.
    >
    > As for the selectedText, in HTML, we can make use of the

    document.selection
    > object, as well as capturing the MOUSEUP event to implement the same
    > function as what the selectedText property in desktop application.
    >
    > For your reference, I copied the whole html below. (I am using JScript for
    > the demonstrating.)
    >
    > ----------------------------
    > <HTML>
    > <HEAD>
    > <TITLE> New Document </TITLE>
    >
    > <SCRIPT LANGUAGE="JavaScript">
    >
    > <!-- Begin
    > var text = "";
    > function getActiveText(e) {
    >
    > // Sets text MSIE or Netscape active
    > // text based on browser, puts text in form
    > text = (document.all) ? document.selection.createRange().text :
    > document.getSelection();
    >
    > document.theform.text.value = text;
    > return true;
    > }
    >
    > document.onmouseup = getActiveText;
    > if (!document.all) document.captureEvents(Event.MOUSEUP);
    > // End -->
    > </script>
    > </HEAD>
    >
    > <BODY>
    > <center>
    > <form name=theform>
    > Highlight any text on the page and JavaScript will 'capture'<br>
    > it in the textbox below. Internet Explorer also allows for <br>
    > the capture of text highlighted within a textbox or textarea: <br>
    > Here's two to try out:<br><br>
    >
    > <input type=text name=demo value="highlight me!"> or <textarea>or

    highlight
    > me!</textarea>
    > <br>
    > <br>
    > Selected text: <input type=text name=text value="">
    > </form>
    > </center>
    >
    >
    > </BODY>
    > </HTML>
    > ---------------------------------------------------
    >
    > Does it answer your question? If I have misunderstood your concern, please
    > feel free to let me know.
    >
    > Best regards,
    >
    > Jacob Yang
    > Microsoft Online Partner Support
    > Get Secure! ¨C www.microsoft.com/security
    > This posting is provided "as is" with no warranties and confers no rights.
    >
     
    Gary Nelson, Oct 30, 2003
    #4
  5. Gary Nelson

    Gary Nelson Guest

    Jacob,

    Thanks for all the help!

    The document.selection.createRange().text does what I need. So I've worked
    it out.

    Gary
     
    Gary Nelson, Oct 30, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nathan Sokalski
    Replies:
    0
    Views:
    919
    Nathan Sokalski
    Oct 17, 2005
  2. =?Utf-8?B?Q2hyaXN0b3BoZSBQZWlsbGV0?=

    CompositeControls: ViewState properties w/ Mapped properties probl

    =?Utf-8?B?Q2hyaXN0b3BoZSBQZWlsbGV0?=, Jan 19, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,141
    Steven Cheng[MSFT]
    Jan 19, 2006
  3. Kent Lichty
    Replies:
    0
    Views:
    838
    Kent Lichty
    Apr 16, 2004
  4. Victor Porton
    Replies:
    1
    Views:
    702
    Steven T. Hatton
    Aug 29, 2004
  5. GTN170777

    asp vbscript textbox paste from word problem

    GTN170777, Oct 9, 2008, in forum: ASP General
    Replies:
    5
    Views:
    289
    B@DJJ
    Oct 17, 2008
Loading...

Share This Page