asp.net mvc - Passing parameters to ASCX user control in MVC -
I am trying to pass string parameters for an ASCX. I want to set it in the text property of the label. In the code given below, it shows that the Biwi tags (ignore% Psychos in HTML tags).
& lt; @ Control language = "c #" Inheritance = "System web.mvc.useuser controllt; string & gt;" & gt; & Lt;% asp: Label ID = "Label2" runat = "server" ** text = "& lt;% # Model% & gt; Test" ** CssClass = "isslabel" & gt; & Lt;% / asp: label & gt; & Lt;% div & gt; & Lt;%: Model% & gt; & Lt;% / div & gt;
Although there is nothing in the label tag which I have placed between the angle brackets in the text field (slightly bold), I can not reveal the parameter I have tried & lt;% : Model%> No Benefits Is it the issue that the code block is inside the quote marks and am I missing some character right now?
Why are you trying to use a web form user control with MVC?
The model believes that it is the string you want to show and you are passing it correctly,
& lt;% HTML.Renderpartial ("MyUserControlView", "My String to Display"); & Gt%;
In your "Parent" page, you will be able to do the following tasks on your ASX:
<% = HTML.Label (model)> gt; %;
& lt; Instead of
If you have many options then you have HTML in one div Labels can wrap the call and specify Div's square (updating your CSS accordingly), you can use a display template or simply use it clearly. Like HTML:
& lt; Label = "someIdThatICouldUseAnotherHtmlExtensionMethodToGet" & gt; & Lt;%: Model% & gt; & Lt; / Label & gt;
The main problem with your code (as it is still stated in @mare comments) is that you are trying to use the web form control in any MVC view Are there.
Comments
Post a Comment