如何组合 Script# 和 Web 控件?

发布于 2024-10-12 19:29:59 字数 982 浏览 1 评论 0原文

我目前在 VS2010 中有一个 Web 应用程序项目。每个控件(在 *.ascx 文件中)以及该控件使用的 Web 服务(在 *.asmx 文件中)和用于操作它的 javascript 对象(在 *.js 文件中)都包含在其自己的单独文件夹中。所以项目布局看起来像这样:

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
  ...

项目正在扩展,我希望使用 Script# 升级和替换 .js 文件。我想保留这种结构,但据我所知,无法在同一项目中混合 Script# 和常规 C# 文件。

我查看了 Script# 网站上的自述文件 PDF,并下载了 PhotoDemo 示例,但我找不到任何使用 Script# 和 Web 控件的示例。我尝试将“脚本支持”模板添加到项目中,然后从 Script# 模板列表中添加类和页面模板,但它们都被视为常规 C# 源代码文件。

我使用 Reflector 来查看由 Script# 安装的 mscorlib、System.Web、ScriptSharp.Web、ScriptSharp.VisualStudio、ScriptSharp 和 Script.Windows 二进制文件,但无法找到任何允许此行为的内容。

有没有人实施过类似的事情或有任何进一步的提示?

目前我设法使用 Script# 的唯一方法是拥有一个单独的 Script# 项目,并将 javascript 文件的输出放在我的 Web 应用程序中。它有效,但不太理想。

感谢您抽出时间,

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 looks 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,
Hugh

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

桜花祭 2024-10-19 19:29:59

我最近冒险尝试并几乎完全停止使用网络用户控件。我将控件 HTML 编译为 Script# 输出,并且使用 WCF 进行 Web 服务调用,而不是回发。我认为你谈到了这一点,但在我看来,如果设计和逻辑位于两个独立的项目中,那么试图同步单个概念单元的设计和逻辑就太麻烦了。

我的项目布局现在基本上如下所示:

WebApp/
  Pages/
    Home.aspx
    [etc]
  Services/
    MainService.svc

ScriptSharp/
  UI/
    Widget1.html
    Widget1.html.cs
    Widget2.html
    Widget2.html.cs

我通过将“.html”文件设置为“编译”来欺骗系统,将其内容转换为 Script# 输出中的常量。在我的“.html.cs”文件中,我有您所期望的内容(用于单击、更改等的事件处理程序),除了 UI 逻辑现在比以前更多地利用 jQuery(这是一件好事)。

如果您有兴趣,可以查看我的 Sharp UI 项目,该项目负责解析 html 常量并将每个 html 片段视为一个 Web 用户控件(客户端版本)。

I'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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文