Solved

mvc, razor

Posted on 2013-10-24
4
513 Views
Last Modified: 2013-10-24
In controller:
public ActionResult Index()
        {
            string inputState = Request.QueryString["inputState"];
            string inputBond = Request.QueryString["inputBond"];
            string userControlID = ServSuretyNetworkRef.GetBondUserControl(inputState, 1, inputBond);
            ViewBag.Message = userControlID;
            return View();
        }

View:
This one below does not work, and need help why and how to fix it? Thanks
@Html.Partial(@ViewBag.Message)


However, the following is working
@Html.Partial("./ControlsAdditionalBondInfo/DefectiveTitle.cshtml")
0
Comment
Question by:solution1368
  • 3
4 Comments
 
LVL 21

Accepted Solution

by:
Craig Wagner earned 500 total points
ID: 39597405
1. What does this have to do with Web Services and WCF? Please choose appropriate topics when posting questions.

2. "does not work" is pretty vague. Run-time error? Compiler error? No error but wrong results?

3. When I tried this I got a compiler error in the View. It stated that extension methods cannot be dynamically dispatched and I should consider casting the dynamic argument. So I did and it worked just fine.

@Html.Partial((string)ViewBag.Message)

Open in new window

0
 

Author Comment

by:solution1368
ID: 39597533
No model for this view it is in the shared folder

And my question is why it is working with the static string n not work in viewbag
0
 

Author Comment

by:solution1368
ID: 39598200
actually, i did test it and @Html.Partial((string)ViewBag.Message) solution is working to me.
adding (string) in the front of viewbag does resolve the string issue.

Thank you for your helps.
0
 

Author Closing Comment

by:solution1368
ID: 39598207
Good lesson to learn for mvc viewbag.message. When a string parameter is passed from the controller to razor engine. Adding (string) will be resolved the debug issue.

Thank you for expert helping.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question