I'm looking for a similar control to the InputFormSection control in Sharepoint that I want to use in a regular web page that doesn't run in the context of Sharepoint. Here's how the inputformsection looks like : http://graegert.com/wp-content/uploads/2008/01/moss_adminarea_page_structure1.png
So do I understand your question correctly? You want to have a control that looks and behave like the InputFormSection control of SharePoint, but it should be able to run outside the context of a SharePoint site?
If so, one approach that you could take is to rip out the generated HTML and use it in your own user control. The IE Developer Toolbar can be of great help to retrieve all other the information (http://www.microsoft.com/en-us/download/details.aspx?id=18359).
It is quite easy to reproduce the control (it is a user control and you have access to the .ascx files). Actually, that's exactly what I ended up doing yesterday.
Related
I am looking to create a widget that can be used with other solutions. The widget is a competition widget that can be placed in different parts of the site.
What is the best way to do this? Should I create a new solution to hold this in?
Create a new class library project (you can have it within your current solution if it suits) and create your server controls in there. You can then reference this library from whatever websites you need.
You need to create a Web Control, not a User Control, if you want o use it in other projects. This question details the different control types, you may find it useful:
What is the difference between UserControl, WebControl, RenderedControl and CompositeControl?
Here is relatively simple tutorial on creating a custom WebControl:
Create ASP.NET Server Controls from Scratch
And here some more advanced example from MSDN:
Developing Custom ASP.NET Server Controls
It depends if you will be using it in other solutions really. If you are, then if might make more sense to create a new widgets solution with each widget in its own user control and compile it into an assembly.
Then you just reference that assembly and use it in your markup.
If your widget is only going to be used in a single solution then I wouldn't bother with the above. Just create a user control in the same solution.
As opposite of some answers, you should create user controls with embedded resources.
It is complex to do it, but once you do you will be able to develop controls like RadControls from Telerik.
If you open up their controls you will see that they are all embedded resources on the Telerik.Web.UI.dll.
Here is an old answer of mine that shows how to load the control and how to handle embedded resources (virtual path provider)
Unless you have a good reason to do so (like creating a generic control as a calendar, grid or something like that) don't go this way, it is dark, complex... But as you can see it might be worth it, Telerik.Web.UI is the live example that this can work out.
My application uses MVVM architecture and needs to occaisonally call some outside asp pages to interact with a few other systems. The problem is I that I really don't want the user to see these pages because they don't have a UI, they really just need to open in the background, perform their function, then close, all without ever being seen. I can not use windowless mode. The URL that I need the frame pointing to is generated in the viewmodel so I also need to know how to get that info to the frame. I'm really lost on this issue as there isn't much online related to doing this without windowless mode. Any help would be much appreicated.
See these two for references in how I pieced the code together for this.
Silverlight, can I access DOM elements in Webbrowser control?
http://www.davidezordan.net/blog/?p=700
Note that the only thing you can do is set the value of the url for that frame if it is in a different domain because of security reasons. That may be fine for you. So try something like:
var element = HtmlPage.Document.GetElementById("yourIframe");
element.SetAttribute("src", yourUrl);
I'm an ASP.NET web part novice. I've built a few simple ones using only a class that derived from WebPart and overriding the CreateChildControls method, but nothing really very substantial. My question is whether it's possible to have a web part that also takes advantage of a separate html/asp.net markup file that will help provide some structure to the web part's output. In the past I just created server controls and added them to the controls collection, but this seems like a silly way to try to create a non-trivial layout. Can I do this? Do I have to use an ascx user control or can I bypass that step? There are a lot of hello world tutorials on web parts out there, but none seem to go past the CreateChildControls override. Thanks!
Yes, there is. Go here to learn about templated web parts, and go here to see all of the info he has on WebParts. I used this technique back in 2004/2005 and it worked very well.
The links in the above answer are no longer working, but here is an alternative one:
http://www.a2zdotnet.com/View.aspx?Id=95
In VS 2010 we also have visual web parts, that I think do pretty much the same trick but it's wrapped in a project item. I've only seen this in the context of SharePoint so not sure how it works for ASP.NET projects. Here is an example:
http://msdn.microsoft.com/en-us/library/ff597539.aspx
Yes that sounds backwards. I want to create an area or frame in my Silverlight app to host another page from my site. I've seen it done before but I can't seem to find any examples.
This way I can control the entire page layout using SL but still use existing aspx pages.
thanks
Yes, it can be done and its quite easy to do. I plan on blogging about my HtmlBrowser control and posting the source. The basics are to make sure the Silverlight control is hosted with the isWindowless parameter enabled and then you can at runtime through the HtmlPage class create an IFRAME element and set the src attribute to the HTML page location. The fun part is getting the sizing right, but its not too difficult.
Follow my blog http://craign.net/ over the next couple of days as I'll post my control.
Will frame break out code break out or not when using this technique.
I wonder what the best practice for this scenario is:
I have a Sharepoint Site (MOSS2007) with an ASPX Page on it. However, I cannot use any inline source and stuff like Event handlers do not work, because Sharepoint does not allow Server Side Script on ASPX Pages per default.
Two solutions:
Change the PageParserPath in web.config as per this site
<PageParserPaths>
<PageParserPath VirtualPath="/pages/test.aspx"
CompilationMode="Always" AllowServerSideScript="true" />
</PageParserPaths>
Create all the controls and Wire them up to Events in the .CS File, thus completely eliminating some of the benefits of ASP.net
I wonder, what the best practice would be? Number one looks like it's the correct choice, but changing the web.config is something I want to use sparingly whenever possible.
So in that case I would wrap it up in a feature and deploy it via a solution. This way I think you will avoid the issue you are seeing. This is especially useful if you plan to use this functionality within other sites too.
You can also embed web parts directly in the page, much like you do a WebControl, thereby avoiding any gallery clutter.
What does the ASPX page do? What functionality does it add? How are you adding the page into the site? By the looks of it this is just a "Web Part Page" in a document library.
I would have to do a little research to be 100%, but my understanding is that inline code is ok, providing it's in a page that remains ghosted, and thereby trusted. Can you add your functionality into the site via a feature?
I would avoide option 1, seems like bad advice to me. Allowing server side code in your page is a security risk as it then becomes possible for someone to inject malicious code. Sure you can secure the page, but we are talking remote execution with likely some pretty serious permissions.
Thanks so far. I've successfully tried Andrew Connel's solution:
http://www.andrewconnell.com/blog/articles/UsingCodeBehindFilesInSharePointSites.aspx
Wrapping it into a solution is part of that, but the main problem was how to get the code into that, and it's more leaning towards Option 2 without having to create the controls in code.
What I was missing:
In the .cs File, it is required to manually add the "protected Button Trigger;" stuff, because there is no automatically generated .designer.cs file when using a class library.
Well, it's a page that hosts user controls. It's a custom .aspx Page that will be created on the site, specially because I do not want to create WebParts.
It's essentially an application running within Sharepoint, utilizing Lists and other functions, but all the functionality is only useful within the application, so flooding the web part gallery with countless web parts that only work in one place is something i'd like to avoid.