Click here to Skip to main content
15,867,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am begginer to mvc.I have one label in mvc view.In controller i have assign text to label like TempData["lblmsg"]="Name:abc pqr".
I want to "Name" word should be bold & other words should be normal.Is it possible in mvc????

Thanks...
Posted

Include Name as <b>Name</b> in tempdata.
 
Share this answer
 
v3
Comments
Rohini Shirke 6-Jan-14 1:11am    
This will not work..
ArunRajendra 6-Jan-14 3:16am    
Sorry wanted to include bold tag. I have updated the solution.
Rohini Shirke 6-Jan-14 3:47am    
This will not work.This will also displays bold tag along with label text.
Bala Selvanayagam 6-Jan-14 6:37am    
Are you able to post me the code in your controller and the view please?
just separate them :)

Hope this helps,
Elieser Legaspi
 
Share this answer
 
Comments
Rohini Shirke 6-Jan-14 1:11am    
Just separate them ...means????
In the controller

XML
public ActionResult Index()
      {
          ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
          TempData["LableText"] = "<b>Code</b> Project";
          return View();
      }



In the view

@Html.Raw(TempData["LableText"].ToString())



Hope this helps
 
Share this answer
 
Comments
Rohini Shirke 6-Jan-14 5:38am    
Thanks.But This will give error in the view at runtime

"An exception of type 'System.NullReferenceException' occurred in App_Web_gal00j1w.dll but was not handled in user code"

Additional information: Object reference not set to an instance of an object.
Rohini Shirke 6-Jan-14 5:41am    
This will work.Thanks
Bala Selvanayagam 6-Jan-14 5:51am    
Glad
Rohini Shirke 6-Jan-14 6:00am    
But there is one more problem..When page is load first time there is no value for TempData["LableText"].then it gives error nullreference exception.In my view when click on button then it sets value for TempData["LableText"].

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900