Forum  Core :: SDK (Vi...  Bug Reports  Pluck a JavaScript Variable in HTML Box and Return to VWG
Previous Previous
 
Next Next
New Post 2/25/2011 9:40 AM
  dmcgrail
166 posts
5th Level Poster


Pluck a JavaScript Variable in HTML Box and Return to VWG 

Could someone please provide a working example of a C# project that fetches a variable from javascript contained in an htmlbox. Please dont point me to a wiki or a VWG article. I've read them all. None pertain exactly to what I'm looking for, or are too far from the exact need. AGAIN - DO NOT POINT ME TO ANOTHER  POST,WIKI or ARTICLE.

I have an htmlbox that is running some html. In that html are javascript functions that do all kinds of cool things. Some of them run on javascript timers and are constantly changing variables. I need a button push event on the main VWG form (the parent hosting the htmlbox) to go down to the html and pluck a javascript variable.

Here is some sample html doing a simplified version of what I need. Please provide a working C# project that shows how to pluck the variable "myCount" and display it in label.text on the parent VWG form.

Thank you very much for your assistance.

Note, I changed all HTML tags < > to [ ] for posting to the forum.


<!--

[HTML]
[HEAD]
[TITLE]Test[/TITLE]

[SCRIPT TYPE="text/javascript" LANGUAGE = "JavaScript"]
var myCount = 0;
function myLoad(){
   setInterval("myRotate()", 1000);
}
function myRotate() {
   myCount++;
   document.myForm.myDisplay.value = myCount;
}
[/SCRIPT]

[/HEAD]
[BODY onLoad="myLoad();" ]

[FORM NAME="myForm"]
   [INPUT value="0" name="myDisplay" READONLY]
[/FORM]

[/BODY]
[/HTML]

-->
 

 
New Post 3/5/2011 3:58 AM
  palli
11838 posts
1st Level Poster




Re: Pluck a JavaScript Variable in HTML Box and Return to VWG 

Hi,

Why would we not refer you to a wiki article or a thread if they contain the information you need to get your answer ?

I will do so in this case, as you are missing some vital points here and I do have a wiki article that will help you get to your answer.

First, you need to realize that placing contents in an HtmlBox and that Html contents are not "connected" to your Visual WebGui application, you do not have a direct link between your Html and your Visual WebGui application. Your HtmlBox's contents do in that case behave like a completely seperate application, and with your code in your post, you don't have any connection server-side between your HtmlBox's contents and your Visual WebGui application.

You do however have a client-side "oppertunity" to get to your HtmlBox contents via the Browser's DOM model, and that's where the dreaded reference to a Wiki article comes into the picture, as you can see in this article here, how to get to the HtmlBox and from there you should be able to get to your javascript within the HtmlBox and execute your function.

When you have established a client side access to your HtmlBox's contents, you will need to got the information you are after to your Visual WebGui application, and for that you will need to raise an event client side and fire it to your Visual WebGui application and for that you can use the ideas from this sample here.

Please let us know if this information is not enough for you to put the pieces together and then we'll see what can be done.

Palli

 

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 3/7/2011 7:59 AM
  dmcgrail
166 posts
5th Level Poster


Re: Pluck a JavaScript Variable in HTML Box and Return to VWG 

As expected. I can't get it to work. I tried using the samples in both of hte Wiki Articles you sent. No Luck. Please take a look at the sample app I sent to support and explain how to pluck the Javascript variable "myCount" or the Form variable "myDisplay".

Thank you.

Also please respond to this article:

http://www.visualwebgui.com/Developers/Forums/tabid/364/forumid/59/threadid/46526/scope/posts/Default.aspx

 
New Post 3/7/2011 12:35 PM
  palli
11838 posts
1st Level Poster




Re: Pluck a JavaScript Variable in HTML Box and Return to VWG 

Hi,

Well, you have got this absolutely correct, except for a minor Html DOM thing.

The only thing you need to change, is inside the ClientInfoRetriever_GetJSVariable javascript function. Below, your original line is the commented one, and the correct one is the uncommented one.

    // var myVar1 = myDoc.myForm.myDisplay.value;
    var myVar = myDoc.contentWindow.myForm.myDisplay.value;
 

Your sample is kinda cool, retrieving values from dynamic Html, so if you don't have any objections, I would like to add it to the ClientInfoRetriever sample?

Regarding your other thread you referenced, we do try the best we can to respond to forum messages as fast as we can, but with free support forums, and very limited resources (especially while closing in on our next release), it's not always possible to respond to every forum post within "acceptible" timeframe, especially when they require substantial amount of time to test and respond to. You will get a response to it as soon as possible though.

Hope this helps,

Palli

 

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 3/8/2011 5:57 AM
  dmcgrail
166 posts
5th Level Poster


Re: Pluck a JavaScript Variable in HTML Box and Return to VWG 
Modified By dmcgrail  on 3/8/2011 9:57:30 AM)

Palli,

Thank you, it works!

Indeed, you may add this to the samples library. I cleaned it up a bit and added a function call to javascript. Now users can see how to call a javascript function and how to retrieve a javascript or DOM variable. Best of both worlds !!

I sent an updated copy of the app to supports email address.

Thnx, Dan

 
Previous Previous
 
Next Next
  Forum  Core :: SDK (Vi...  Bug Reports  Pluck a JavaScript Variable in HTML Box and Return to VWG
Azure banner
.NET Web, Cloud and Mobile application delivery platform | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2011 Visual WebGui®       Visual WebGui weblog on ASP.NET Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS