Forum  General Visual ...  How do I...?  Communicate from a wrapped Control with VWG
Previous Previous
 
Next Next
New Post 5/24/2012 9:29 AM
  neobender
26 posts
No Ranking


Re: Communicate from a wrapped Control with VWG 
Modified By neobender  on 5/24/2012 12:30:38 PM)

Hello Palli,

Thank you for replying. I did that for my controls HTML:

 

 <script src="Resources.Gizmox.WebGUI.Forms.Skins.CommonSkin.Interfaces.js.wgx" type="text/javascript"></script>

It also seems to that the VGW.Events is available but I get an Server-Error if I use "<%= PageContext.ID %>". The Error says that the Name "PageContext" is not available in the current Context. So which ID should I use to send an event to my base Form?

 

 

 
New Post 5/24/2012 3:11 PM
  palli
14299 posts
1st Level Poster




Re: Communicate from a wrapped Control with VWG 

 Hi,

Yes, the reference to <% PageContext.ID %> is an AS.NET preprocessor variable and will be replaced with the Visual WebGui Control ID of the AspPageBox control (AspPageBox.ID). This works as the example is within a WebForm, but as your's is a wrapper and not within a WebForm, you will not have this variable. 

You need to find a way to get the AspControlBoxBase.ID to the CreateEvent method so it will fire the Visual WebGui client event towards the correct control, the one you have the FireEvent override defined on server-side. 

If you can't figure it out, you are welcome to email your application to support (see my signature for the email address) and we will take a look. If you choose to do so, please include in that email the Http link to this thread so we can pair it with the email and also please add a new message here when you have sent the email.

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 5/24/2012 5:40 PM
  neobender
26 posts
No Ranking


Re: Communicate from a wrapped Control with VWG 

E-Mail send, the Sample-Project is in the E-Mail or here. If you don't mind I would share the respones here.

 
New Post 5/25/2012 1:56 PM
  palli
14299 posts
1st Level Poster




Re: Communicate from a wrapped Control with VWG 

 Hi neobender,

As I see that you already linked your project, I assume you have no objections that I upload the modified version of it where I have added some simple JavaScript capable of firing an event to the Visual WebGui application. 

Your remaining problem is that you need to control ID of the Visual WebGui wrapper control in order to be able to raise the client side Visual WebGui event to the correct server-side control. It is always interesting to view the rendered Html when figuring out the structure you need to account for, but the basic idea is that you need some starting DOM node and then start traveling up the DOM tree until you find a node that can give you this information. In the case of an ASP.NET wrapped control, it will be rendered inside an IFrame and you simply travel up the tree until you find one with id="TRG_xxx" where "xxx" is the Visual WebGui control ID. 

The JavaScript code to do that could be something like this:


function getVWGcontrolID(objStartNode) {
    var objCurNode = objStartNode;
    while (objCurNode != null) {
        if (objCurNode.parentNode)
            objCurNode = objCurNode.parentNode;
        else
            return "undefined";
        if (objCurNode.frames) {
            if (objCurNode.frames.frameElement) {
                if (objCurNode.frames.frameElement.id) {
                    var strID = objCurNode.frames.frameElement.id;
                    if (strID.substring(0, 4) == "TRG_")
                        return strID.substring(4);
                }
            }
        }
    }
    return "undefined";
}
To call it, you need a starting DOM node as I already mentioned. Looking at the JavaScript already in the .aspx file, I notice that a variable "theForm" is set, so we can as well use it for this purpose. 
You simply comment out the alerting line and place the following code:

var v = VWG.Services.GetApplication();
var strID = getVWGcontrolID(theForm);

var objEvent = VWG.Events.CreateEvent(strID, "message");
VWG.Events.SetEventAttribute(objEvent, "messagetext", "Test");
VWG.Events.RaiseEvents();
 
 
This should get your Visual WebGui client side event fired against the wrapper server-side control, and if you set a breakpoint on the FireEvent override, your breakpoint should be hit.
 
I uploaded the modified version of your project here.
 
Hope this helps,
Palli
 
 

Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 6/1/2012 7:59 AM
  neobender
26 posts
No Ranking


Re: Communicate from a wrapped Control with VWG 
Modified By neobender  on 6/1/2012 11:02:38 AM)

Hello Palli,

Thank you for reply, it finally works. But now the the VWG Javascript Function "Events_CreateEvent" returns an error if the WrappedControl makes a Postback. It seems that is caused by the var "mobjDataDomObject" which is null, so calling the Function "createElement" fails.

Kind Regards

 

EDIT

It seems that this happens in general, even if I undo the changes.

 
Previous Previous
 
Next Next
  Forum  General Visual ...  How do I...?  Communicate from a wrapped Control with VWG
.NET HTML5 Web, Cloud and Mobile application delivery | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2012 Visual WebGui®       Visual WebGui weblog on ASP.NET Gizmox Blog Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS