spano

Hi, I want to host a win forms control in SharePoint.

I added the following to the master page:

<object id="MyControl1"
classid="http:MyControl.dll#MyControl.UserControl1"
height="500" width="500" VIEWASTEXT>
</object>

and placed MyControl.dll in the web application virtual directory root.

The page is in a trusted site, but the control is not showing up.

Am I placing the dll in the right place Do I need further configuration

Thanks!

Sole




Re: SharePoint - Development and Programming Hosting a win forms control in a master page

MKeeper

Erm ... you can't use Windows Form user controls in SharePoint. you need to use either:

Web User Control (*.ascx)

Web Custom Control (*.dll)

If you are building Web User Controls, I recommend that you place your ASCX file in the Template\ControlTemplates\ folder, preferably in a sub-directory.

The "ControlTemplates" directory is one of the "Safe Control" locations in SharePoint (I believe the Template\Layouts folder is another one).

Lets assume you've built a Custom Control called "MyControl.ASCX" and placed it in the "CustomControls" sub directory of the ControlTemplates folder.

You could then access your control from the following URL:

\_controltemplates\CustomControls\MyControl.ASCX

You can then register your control in the Master Page by using the Register at the top opf the page.

(a quick google should help you in registering ASCX files in master pages).

That will allow you to use the TagPrefix:TagName methodology to use your control.

Hope this is clear, if you didn't get the terminology try Google or give me a shout.






Re: SharePoint - Development and Programming Hosting a win forms control in a master page

spano

Thanks for the reply, but...why do you say I can't use win form controls in SharePoint I know win form controls can be hosted in aspx pages (see http://www.15seconds.com/issue/030610.htm). Shouldn't the work in SharePoint, too

I need to run code on the client side, so I guess the controls you suggest won't work for me. Thanks,

Sole






Re: SharePoint - Development and Programming Hosting a win forms control in a master page

Ayub Patel

place your dll in the bin directory of your website. Or gac the dll






Re: SharePoint - Development and Programming Hosting a win forms control in a master page

MKeeper

spano wrote:

Thanks for the reply, but...why do you say I can't use win form controls in SharePoint I know win form controls can be hosted in aspx pages (see http://www.15seconds.com/issue/030610.htm). Shouldn't the work in SharePoint, too

I need to run code on the client side, so I guess the controls you suggest won't work for me. Thanks,

Sole

Well it depends what you mean by a "Windows Forms User Control".

Typically, such a control will be using Windows Forms objects, which are not valid in Web Applications.

What you might be doing is using it as a Class Library and building your functionality in code (and not using any specific windows form classes) in which case you are kind of building a "custom control".

As far as I was aware you cannot use any objects in the Microsoft.Windows namespace in a web application.






Re: SharePoint - Development and Programming Hosting a win forms control in a master page

MKeeper

Hmmm ... ok, I stand corrected.

Although I think the method described in that link you provided is a bit .. well .. dodgy.

I also doubt that such a method would work in FireFox / Opera / etc

I always thought that the best way to provide a rich web experience in SharePoint was to either use Java or AJAX (which is technically still Java) or .. if you really feel the need .. Flash.

Using Windows controls in a web application is a very much "square peg - round hole" approach and I think you should consider what you are doing and why you are doing before going down such a route.

regards

MKeeper






Re: SharePoint - Development and Programming Hosting a win forms control in a master page

spano

Ayub Patel wrote:

place your dll in the bin directory of your website. Or gac the dll

I place an html test page in the virtual dir root (in my case C:\Inetpub\wwwroot\wss\VirtualDirectories\47607). I tried placing the dll in the same dir and referencing it from the html page by: classid="http:MyControl.dll#MyControl.UserControl1" .

I also tried placing the dll in the bin dir ( C:\Inetpub\wwwroot\wss\VirtualDirectories\47607\bin ) and referencing it from the html page like this: classid="http:bin/MyControl.dll#MyControl.UserControl1".

It work neither way.

Is the sintax ok

Thanks,

Sole






Re: SharePoint - Development and Programming Hosting a win forms control in a master page

Ayub Patel

You also need to make entry of your dll as a safe control in your web config file






Re: SharePoint - Development and Programming Hosting a win forms control in a master page

spano

Ií»ve solved the problem and posted the solution in my blog. Thanks to all.