如何在MVC中编写这个ASP.NET控件? [英] How to code this ASP.NET control in MVC?

查看:66
本文介绍了如何在MVC中编写这个ASP.NET控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是asp.net mvc的新手。我对mvc的工作原理有基本的了解。

我的视图中有一个注销面板,我想在其中添加文字控件。我在aspx和aspx.cs中尝试过。

我不知道如何在mvc中这样做。

aspx.cs



这个.LogoutPanel.Controls.Add(new LiteralControl(String.Format(

 < img width ='1px'src ='{0}?wa = wsignoutcleanup1.0'+title ='退出请求:{0}?wa = wsignoutcleanup1.0'/>

i am completely new to asp.net mvc. I have basic knowledge of how mvc works.
I have a logout panel in my view and i want to add the literal control inside it.I have tried in aspx and aspx.cs.
I have no idea how to do it in mvc.
aspx.cs

this.LogoutPanel.Controls.Add(new LiteralControl(String.Format("

 <img width='1px' src='{0}?wa=wsignoutcleanup1.0' " + "title='Signout request: {0}?wa=wsignoutcleanup1.0'/>

 < img width ='1px'src ='{0}?wa = wsignoutcleanup1.0'+ title ='登出请求:{0}?wa = wsignoutcleanup1.0'/>

 <img width='1px' src='{0}?wa=wsignoutcleanup1.0' " + "title='Signout request: {0}?wa=wsignoutcleanup1.0'/>

推荐答案

你刚才将img标记放在视图中,并将所需的URL放在您传递给视图的模型中(或ViewBag,但模型更好)



You just put the img tag in the view and put the desired url in the model you pass to the view (or the ViewBag but model is better)

<img src="@Model.LogoutUrl"/>


这篇关于如何在MVC中编写这个ASP.NET控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆