ASP.net MVC rendering html pages - asp.net-mvc

I have HTML Pages in my ASP.net MVC project. How can i render these pages with dynamic values.
Index.html
< input type="text" value=<%=Dynamic Value Here%> />

You can't since HTML files will not be parsed by the ASP.NET MVC view engine and it won't understand the server side syntax you will need to insert dynamic values. In order to do this you will need to translate your HTML files into aspx files to use the webforms view engine syntax of <%: %> or cshtml files to use the razor syntax of #. Now you will be able to insert dynamic values since the view engine will insert those values into the HTML that is returned to the browser to be rendered.

Related

Insert blazor component that has cascading value parameters within cshtml page

I've recently introduced blazor components into my Razor pages project. Until now, my website endpoints have used either exclusively blazor components (.razor) or exclusively razor pages (.cshtml). I am now tring to insert blazor components within my cshtml pages. The problem arrises because I have set up default cascading values, such as an Access Token string and CascadingAuthenticationState in my App.razor page. I don't know how to set these within my cshtml page, as the cshtml page does not like the or components.
I am calling a blazor component like so from a cshtml page:
...
<div>
<component type="typeof(ProcessEditor)" render-mode="ServerPrerendered" param-Id="Model.Id" />
</div>
...
How do I supply this with the needed cascading values and authentication state?

ASP.NET MVC renders html tags & attributes in lowercase

It seems that both Asp.net MVC Core and Asp.net MVC 5.x render html tags & attributes in lowercase and this behavior breaks angular bindings. To give an example: in my view.cshtml I define Angular component with camel case binding:
<my-component [fooBar]="foo"></my-component>
which is later rendered as:
<my-component [foobar]="foo"></my-component>
As far as Angular bindings are case-sensitive, input-property fooBar inside component remains undefined. Is there any way to override this rendering behavior and render html as-is?
When I put this in a cshtml file:
<test-tag [testingThisThing]="123" anotherThingTEST="abc"></test-tag>
I get exactly the same in the HTML source. Are you sure that the element isn't being modified after loading? Are you looking at "View Source" (not "Inspect Element")?
That said, my test-tag isn't defined as anything anywhere - are you using Tag Helpers or something? MVC itself doesn't lowercase all attributes.
Looking at view source, it appears that it is being rendered by razor as written, but when the element actually appears in chrome, it is lower-cased. I can only assume this is a chrome "feature".

How to convert the data into html reading from data base

I am developing an application in which I have used the editor so when the user submit the data the data was send to the sql server in HTML format.
<p><strong><em>fghfghfghfghfghfghfgdfxvbc</em></strong></p> <ol> <li>.
it will not converted in to html tags.
I'm using Asp.net Mvc.
The code is as follow:
When adding raw HTML to a page in ASP.NET MVC, you need to use
#Html.Raw("your html string here")

ASP.Net MVC .cshtml page i hae html dropdowenlist.How i get dropdowenlist in controller

I have simple .cshtml page have one HTML drop down list box how i get drop down list value in controller.ASP.Net MVC .cshtml page i hae html dropdowenlist.How i get dropdowenlist in controller
Possible way to get the Dropdownlistcontents to the controller:
1) selecting all elements in the dropdownlist(possible Jquery) and create and Object(preferably JSON)
2) post the object to controller
Hint: You should not work with pure strings , because MVC tends to do things you don`t expect,if you do not understand it.
Worth a read:
http://vault.lozanotek.com/archive/2010/04/16/posting_json_data_to_mvc_controllers.aspx

How to include contents of plain HTML or classic ASP file in an ASP.net MVC 3 view?

I'm working on an ASP.net MVC 3 application. I have an external classic ASP file that renders a fragment of a page.
I understand that in ASP.net MVC 3, I can define a partial view to contain a fragment of HTML that I want to reuse on multiple pages.
The basic idea that I have is that I would like to use an external classic ASP file to render a fragment of HTML in my ASP.net MVC 3 application.
I would like to use it with something like Html.Partial, but that won't work because a classic ASP file is obviously not an MVC partial view.
Another way of doing this would be to add the content of the file to the page with AJAX, but I don't want to add the overhead of another AJAX call to my page. What might be the solution I'm looking for?
Plain HTML: Just read it from disk and output it with #Html.Raw().
Asp or other dynamically created content: You may use HttpWebRequest to get the html markup, and then insert into you own view. You may want to cache the response.
For convenience, you may create extension methods for both methods.
Create a Controller Action that makes the external call and returns the content:
Html.RenderAction("GetContent","ExternalASP"); //GetContent- Action, ExternalASP- Controller

Resources