Textbox Properties from VBScript

G

Gary Nelson

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
 
J

Jacob Yang [MSFT]

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.
 
J

Jacob Yang [MSFT]

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.
 
G

Gary Nelson

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
 
G

Gary Nelson

Jacob,

Thanks for all the help!

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

Gary
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top