Is there any way to use a string on a page using a master layout and calling a section?
So instead of this:
@section SomeSection
I could do this?
@section "SomeString"
Or better
@section SomeClass.SomeConstantString
Reason for this? So that I can use a constant string on the master page for the section name and use the same constant string on the partial page.
@RenderSection(eClass.SomeConstantString, required:false)
I'm really hoping there is a way to do this otherwise it seems like an issue overall.
To declare a variable in the View using Razor syntax, we need to first create a code block by using @{ and } and then we can use the same syntax we use in the C#. In the above code, notice that we have created the Code block and then start writing C# syntax to declare and assign the variables.
Using @: to explicitly indicate the start of content.
Rendering a Partial View You can render the partial view in the parent view using the HTML helper methods: @html. Partial() , @html. RenderPartial() , and @html. RenderAction() .
The @: sequence indicates that the line of content that follows should be treated as a content block: ("razor at colon" in Google).
No, this is not possible. I don't see that as that big of a limitation because if the layout is rendering a required section and the names do not match you'll het an error at runtime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With