15,905,967 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 12953926 (Top 7 by date)
Member 12953926
29-Jan-24 9:23am
View
hi Richard,
Thanks for the above suggestions. Its working perfect for windows virtual machines. very recent i have noticed In linux VM when i name a partial view with few names like _CTS.cshtml,_Cpl_Scrn.cshtml,_CTC.cshtml is not working. Should i follow any naming convention when i create partial view for Linux machines ?
Member 12953926
13-Dec-22 7:46am
View
Its works with Plain HTML code.
Now the situation is with C# code.
For Example:
Page 1 description:
var input = "Hello This is Same{partv _AllPages}Some Content{partv _AllPost}";
Page 2 description:
var input = "Hello This is Same{partv _AllPages}Some Content";
Html.Partial("_AllPosts") ==> having C# code for getting the dynamic data.
Output: Now if I load Page 2 in browser, control is going to Html.Partial("_AllPosts") partial view page(_AllPosts.cshtml). Not sure why. For Page 2 it should not go. Because the short code is not present in description column.
Member 12953926
13-Dec-22 7:20am
View
Actually i want to define the Partial View dynamically(without Ajax). Like short code. If the short code exists in the description,, then that should be replaced with the Partial view. Any thoughts on this ?
Member 12953926
13-Dec-22 6:02am
View
hi Richard. There is one issue..
in the above script - var input = "Hello This is Same{partv _AllPages}Some Content{partv _AllPost}";
i have removed one partv and its now
var input = "Hello This is Same Some Content";
In the result its calling Html.Partial("_AllPages") and Html.Partial("_AllPosts"). They should be get replaced if its exists in input.
This time in Html.Partial("_AllPages") and Html.Partial("_AllPosts") i have added C# code. Please help.
Member 12953926
2-Sep-22 7:01am
View
hi Richard, The above scrip work perfects. Can we cut-shot the script? Because there will be around 200+ partial view in my project. Is there any better way to do?
Member 12953926
10-Aug-22 12:36pm
View
Thanks a Lot. It worked.
Member 12953926
10-Aug-22 2:59am
View
hi thanks for the solution. I have tried it. It gives error. Use of unassigned local variable 'replacement'. Please help
Here what i tried:
@{
var input = "Hello This is Same{partv _AllPages}Some Content{partv _AllPost}";
var replacements = new Dictionary<string,ihtmlcontent>
{
["{partv _AllPages}"] = Html.Partial("_AllPages"),
["{partv _AllPosts}"] = Html.Partial("_AllPosts"),
};
string output = input;
foreach (var pair in replacements)
{
if (!output.Contains(pair.Key)) continue;
string replacement;
using (var writer = new StringWriter())
{
pair.Value.WriteTo(writer, HtmlEncoder.Default);
}
output = output.Replace(pair.Key, replacement);
}
}
@Html.Raw(HttpUtility.HtmlDecode(output))
Show More