gpt4 book ai didi

c# - 我可以像在 asp.net mvc 中那样在 Webforms 项目中创建 html 助手吗?

转载 作者:太空狗 更新时间:2023-10-30 00:46:30 25 4
gpt4 key购买 nike

我可以像在 asp.net mvc 中一样在 Webforms 项目中创建 html 助手吗?谢谢。

最佳答案

到目前为止,这是一个在我有限的使用范围内对我有用的

public static class PageCommon
{
public static System.Web.Mvc.UrlHelper GetUrlHelper(this System.Web.UI.Control c)
{
var helper = new System.Web.Mvc.UrlHelper(c.Page.Request.RequestContext);
return helper;
}
class ViewDataBag : IViewDataContainer
{
ViewDataDictionary vdd = new ViewDataDictionary();
public ViewDataDictionary ViewData
{
get
{
return vdd;
}
set
{
vdd = value;
}
}
}
public static System.Web.Mvc.HtmlHelper GetHtmlHelper(this System.Web.UI.Control c)
{
var v = new System.Web.Mvc.ViewContext();
var helper = new System.Web.Mvc.HtmlHelper(v, new ViewDataBag());
return helper;
}

关于c# - 我可以像在 asp.net mvc 中那样在 Webforms 项目中创建 html 助手吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3128518/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com