?
Solved

mvc, razor

Posted on 2013-10-24
4
Medium Priority
?
532 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 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Integration Management Part 2
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month16 days, 5 hours left to enroll

850 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