Solved

mvc, razor

Posted on 2013-10-24
4
510 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Pass through dll 2 33
c# code 19 56
C# SQL BULK INSERT CLASS 5 33
ASP.Net Session State alternatives 3 26
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…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now