tags:

views:

53

answers:

1

I have a text area

<%=Html.TextArea("CDescr", "", new { Class = "textarea1" })%>

I want to set value to this textare from controller. How can I do that ?

A: 

Add the value in the Action method to the ViewData:

public ActionResult Index()
{
  ViewData["MyValue"] = "Some text";
  return View();
}

Then, use the value to set the text:

<%=Html.TextArea("CDescr", ViewData["MyValue"], new { @class = "textarea1" })%>
Dave Swersky
I tried that also. But it gives error saying that "the best extension method overload 'System.Web.Mvc.Html.TextAreaExtensions.TextArea(System.Web.Mvc.HtmlHelper, string, string, object)' has some invalid arguments"For that I found a solution. I type casted ViewData to string like this..><%=Html.TextArea("CDescr", (string)ViewData["CName"], new { Class = "textarea1" })%>It worked... :) Thank you for your reply...
Raghavendra HG