Solved

mvc, razor

Posted on 2013-10-24
4
519 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Amazon S3 .Net error 5 43
itextsharp with c# 3 18
Data organization issue 7 37
Images showing on the internet -- asp.net -- VB.net.  Why some do and some don’t. 3 26
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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