How do I combine Script# and Web Controls?
I currently have a Web Application project in VS2010. Each control (in *.ascx files) is contained in it's own separate folder along with the web services used by that control (in *.asmx files) and the javascript object used to manipulate it (in *.js files). So the project layout loo开发者_StackOverflow中文版ks something like:
WebApp/
WebControl1/
WebControl1.ascx
WebControl1.ascx.cs
WebControl1.ascx.designer.cs
WebControl1.asmx
WebControl1.asmx.cs
WebControl1.js
WebControl2/
...
Global.asax
Default.aspx
Default.aspx.cs
Default.aspx.designer.cs
...
The project is expanding and I'm looking to upgrade and replace the .js files using Script#. I'd like to maintain this structure but as far as I can tell there's no way to mix Script# and regular C# files in the same project.
I've looked at the Readme PDF on the Script# site and downloaded the PhotoDemo example but I can't find any examples of using Script# along side Web Controls. I've tried adding the 'Script Support' template to the project and then adding both Class and Page templates from the Script# template list but they both get treated as regular C# source code files.
I've used reflector to look into the mscorlib, System.Web, ScriptSharp.Web, ScriptSharp.VisualStudio, ScriptSharp and Script.Windows binaries that are installed by Script# and haven't been able to find anything that would allow this behaviour.
Has anyone implemented something similar or have any further hints?
The only way I've managed to use Script# at the moment is to have a separate Script# project and have the output for the javascript files be inside my Web Application. It works, but is less than ideal.
Thanks for your time,
HughI've recently taken the plunge and have stopped using web user controls almost entirely. I compile my control HTML into Script# output, and instead of postbacks I make web service calls with WCF. I think you touch on this, but in my view it's just too much of a hassle trying to synchronize the design and logic of what is a single conceptual unit if the design and logic are in two separate projects.
My project layouts essentially look like this now:
WebApp/
Pages/
Home.aspx
[etc]
Services/
MainService.svc
ScriptSharp/
UI/
Widget1.html
Widget1.html.cs
Widget2.html
Widget2.html.cs
I trick the system by setting my ".html" files as "Compile", turning their contents into constants in the Script# output. In my ".html.cs" files I have what you would expect (event handlers for click, change, etc) except the UI logic now utilizes jQuery more than before (a good thing).
If you're interested you can check out my Sharp UI project which takes care of parsing the html constants and treating each html fragment as if it were a (client-side version of a) web user control.
精彩评论