Forum  Commercial Foru...  Commercial Foru...  Gateway
Previous Previous
 
Next Next
New Post 12/12/2011 8:51 AM
  fido1234
21 posts
No Ranking


Gateway 

Hi I'm trying to understang how Gatways work.

I prepared a very simple project with a custom control that implements the IGatewayComponent interface (I found an example on-line http://www.visualwebgui.com/Developers/KB/tabid/654/article/using_visual_webgui_gateways_in_a_simpler_way/Default.aspx)

The project does not work, no errors but I do not see anything. If I send you the small project, could you see what is missing?

Thank you

Giuliano C.

 
New Post 12/12/2011 9:20 AM
  palli
14304 posts
1st Level Poster




Re: Gateway 

Hi Guiliano C,

Yes, sure, we'll look over your project and see what may be wrong.

Simply zip it and email to the support address (see my signature). Please remember to include in that email the full Http reference to this thread and please also add a post here when you have sent the email.

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 12/12/2011 10:34 AM
  fido1234
21 posts
No Ranking


Re: Gateway 

Hi

I just sent you the project.

Thank you

Giuliano C.

 

 
New Post 12/12/2011 11:16 AM
  palli
14304 posts
1st Level Poster




Re: Gateway 

Hi Giuliano C,

We received your project and I have taken a look.

The path you have chosen is to create a Custom Control, which is just fine, but you have to make some adjustments before you can expect the control to be rendered to your form.

First, regarding custom control, then from the attributes on your custom control, the MetaDataTag and Skin are the most relevant. The MetaDataTag is telling the rendering engine what type of control it should render, and as you are not supplying any XSLT, and you clearly want your control to be rendered as a normal PictureBox, then you should simply not set the MetaDataTag, and then it will inherit this setting from it's parent class, the PictureBox. The same rule applies to the Skin attribute. You're not changing any of the client resources, so you don't need it. Should you want to add some client resources (JavaScript etc...) you should make the Skin class inherit from PictureBoxSkin, and then add your additional client resources.

As I understand from your demo application, you are only customizing the server-side of the control, and in that case you really don't need it to be a custom control. Simply go right-click on your project, select Add / Inherited Control and select the Gizmox.WebGUI.Forms.PictureBox as the control to inherit from.  This is a much simpler method, because then you don't have to worry about the extra stuff added by the Custom Control template. If you still want to go the Custom control way, then you should remove all the attributes from the class, and then remove the RenderAttributes method as well as the Text Property, after which you can delete the MyCustomControlSkin, as you will be using the default builtin PictureBoxSkin.

Anyway, using the Inherited control method, you can place this code in your control:

	public partial class MyPictureBox : PictureBox
	{
		public MyPictureBox()
		{
			InitializeComponent();
            if (this.ID == 0)
                this.RegisterSelf();
            this.Image = new GatewayResourceHandle(new GatewayReference(this"test"));
            this.SizeMode = PictureBoxSizeMode.Normal;
		}
 
        protected override IGatewayHandler ProcessGatewayRequest(Gizmox.WebGUI.Hosting.HostContext objHostContext, string strAction)
        {
            // Create a simple Image
            Bitmap objBitmap = new Bitmap(10, 10);
            Graphics objGraphics = Graphics.FromImage(objBitmap);
            objGraphics.FillRectangle(new SolidBrush(Color.Red), 0, 0, 10, 10);
            objHostContext.Response.ContentType = "image/jpeg";
            objBitmap.Save(objHostContext.Response.OutputStream, ImageFormat.Jpeg);
 
            return null;
 
        }

Please note the two changes I made there. First, the "test" parameter to the GatewayReference constructor. Because how an Url is formed out of a GatewayRequest, it doesn't like an empty string, so place some dummy string there and you should be fine.

Second, the RegisterSelf() call deserves a special mention here. Every control (component) on a form in Visual WebGui will receive a unique ID when it's added to the form. This ID is used for the gateway request, as you can see if you view the rendered Html after you have shown the PictureBox. The way you construct your control, you are using the control's ID within the constructor. The constructor is invoked before the ID has been allocated, and as you are using the ID within the constructor (getting the GatewayReference to it), you must help with the process and make sure the ID is allocated before you use it. That's why you need to call RegisterSelf() in the constructor. This makes sure the ID is allocated, so you can use it in the next statement.

If you would skip this step of calling RegisterSelf(), your gateway request would always be issued against a component with the ID=0, which will most likely cause your gateway request to be "lost at sea", so to speak, and never reach your application, at least not your Picturebox.

Hope this explains,

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 12/12/2011 11:54 AM
  fido1234
21 posts
No Ranking


Re: Gateway 

Thank you very much

Now it works!

Giuliano C.

 
Previous Previous
 
Next Next
  Forum  Commercial Foru...  Commercial Foru...  Gateway
.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