ASP.NET - 使用自定义标签和事件处理创建自定义页面

发布于 2024-08-25 00:57:59 字数 433 浏览 3 评论 0原文

我正在尝试一些代码,这些代码使我能够创建扩展名为 .asp2 的页面。

其中包含的标签也将是自定义的,例如:

<asp2:H>
  <asp2:T>
    First Page
  </asp2:T>
</asp2:H>
<asp2:B>
  <asp2:D>
    <asp2:Label>Welcome......</asp2:Label>
  </asp2:D>
</asp2:B>

我已经完成了必要的更改,以便 ASP.NET 识别扩展名。我还自己保存了自定义标签和 asp.net/html 标签的映射。这样我就可以在浏览器上渲染页面了。但是在这种情况下我们如何进行事件处理(通常通过页面回发和代码完成)???

请建议

I am trying out some code which enables me in creating a page with extension .asp2

The tags included will also be custom, something like:

<asp2:H>
  <asp2:T>
    First Page
  </asp2:T>
</asp2:H>
<asp2:B>
  <asp2:D>
    <asp2:Label>Welcome......</asp2:Label>
  </asp2:D>
</asp2:B>

I have done the necessary changes so that ASP.NET identifies the extension. I have also kept a mapping of custom tags and asp.net/html tags with myself. With this I am able to render the page on browser. But how can we do event handling(usually done by page postbacks and code) in such a scenario???

Please suggest

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

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

发布评论

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

评论(1

魂牵梦绕锁你心扉 2024-09-01 00:57:59

ASP.NET 使用客户端 __doPostBack(id, event) 方法来触发到服务器的回发。您可以检查运行 ASP.NET 页面时加载的 JS 代码,以了解它所做的一切。在客户端上,它存储 __EVENTTARGET 和 __EVENTARGUMENT 表单值来标识导致回发的控件,并随后创建事件。

您必须完成所有这些工作,或者找到一种方法来包装现有组件,这样您就不会失去这些基础知识。

HTH。

ASP.NET uses a client-side __doPostBack(id, event) method to trigger the postback to the server. You can inspect the JS code that's loaded when you run an ASP.NET page to see all that it does. On the client, it stores an __EVENTTARGET and __EVENTARGUMENT form values to identify the control that caused the postback, and subsequently create an event.

You would have to do all this plumbing, or figure out a way to wrap existing components so that you don't lose those fundamentals.

HTH.

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