Pass value from Controller to @HTML.TextBoxA potentially dangerous Request.Form value was detected from the clientasp.net mvc - obtain values from a bunch of inputs selectivelyASP.NET MVC Unbind Action ParameterHow do I get the value of an input of html.textbox in ASP.NET MVC 2Is viewbag the best option?TextBox(HtmlHelper, String) - is view model also searched for a value?mapping json returned from controller to strongly typed viewget a variable passed to my controller from a textboxMove Processing from the View to a controllerProblem adding string value to ViewBag from an MVC Action using TempData

Delete elements less than the last largest element

How do I talk to my wife about unrealistic expectations?

Decrease spacing between a bullet point and its subbullet point

Is there a formal/better word than "skyrocket" for the given context?

Need a non-volatile memory IC with near unlimited read/write operations capability

Strong Password Detection in Python

Moving millions of files to a different directory with specfic name patterns

Why the Cauchy Distribution is so useful?

Write a function

How do resistors generate different heat if we make the current fixed and changed the voltage and resistance? Notice the flow of charge is constant

What do you call a situation where you have choices but no good choice?

Why am I getting unevenly-spread results when using $RANDOM?

What are the effects of abstaining from eating a certain flavor?

Users forgotting to regenerate PDF before sending it

Findminimum of Integral

How to evaluate the performance of open source solver?

How do ballistic trajectories work in a ring world?

My professor has told me he will be the corresponding author. Will it hurt my future career?

How to use Adostop Eco stop bath?

US citizen traveling with Peruvian passport

Is it okay to use open source code to do an interview task?

How should I ask for a "pint" in countries that use metric?

Why did Old English lose both thorn and eth?

Is it possible for a character at any level to cast all 44 Cantrips in one week without Magic Items?



Pass value from Controller to @HTML.TextBox


A potentially dangerous Request.Form value was detected from the clientasp.net mvc - obtain values from a bunch of inputs selectivelyASP.NET MVC Unbind Action ParameterHow do I get the value of an input of html.textbox in ASP.NET MVC 2Is viewbag the best option?TextBox(HtmlHelper, String) - is view model also searched for a value?mapping json returned from controller to strongly typed viewget a variable passed to my controller from a textboxMove Processing from the View to a controllerProblem adding string value to ViewBag from an MVC Action using TempData






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have a search functionality in the Index page with search options that results in Grid with Details link(another page), I am redirecting to Details page. From details page to Index page I need to retain the search criteria.



I am using ViewBag to store the values and and able to see the value in the Index.cshtml but the value is not assigned in the TextBox



Controller:



public ActionResult Index(string type)

try

if (type == "Search")

ViewBag.Id = 100;
return View();


catch (Exception ex)

ViewBag.ErrorMessage = "An error occurred: " + ex.Message;
return View();




Index.cshtml:



@Html.TextBox("txtID", (string)ViewBag.Id, new id = "txtID", @class = "input" )


Generated HTML:



<input class="inputBox" id="txtID" name="txtID" type="text" value="100">


The generated output is having the value as 100, but the value is not assigned to the Textbox and it is displaying Empty/Null.



How to assign the ViewBag value to @HTML.TextBox










share|improve this question
























  • I have used the suggested above and the generated html is <input type="text" id="txtID" name="txtID" value="100"> Still the value is not displaying in the textbox

    – Andy
    Mar 25 at 23:05












  • see this example (dotnetfiddle.net/Pyk2db)

    – Ajeet Kumar
    Mar 26 at 3:36











  • Thank you Ajeet Kumar. your example is perfect, but still the value is not visible in the TextBox. The generated HTML is same, still the value is not being assigned to the textbox.

    – Andy
    Mar 26 at 7:53

















0















I have a search functionality in the Index page with search options that results in Grid with Details link(another page), I am redirecting to Details page. From details page to Index page I need to retain the search criteria.



I am using ViewBag to store the values and and able to see the value in the Index.cshtml but the value is not assigned in the TextBox



Controller:



public ActionResult Index(string type)

try

if (type == "Search")

ViewBag.Id = 100;
return View();


catch (Exception ex)

ViewBag.ErrorMessage = "An error occurred: " + ex.Message;
return View();




Index.cshtml:



@Html.TextBox("txtID", (string)ViewBag.Id, new id = "txtID", @class = "input" )


Generated HTML:



<input class="inputBox" id="txtID" name="txtID" type="text" value="100">


The generated output is having the value as 100, but the value is not assigned to the Textbox and it is displaying Empty/Null.



How to assign the ViewBag value to @HTML.TextBox










share|improve this question
























  • I have used the suggested above and the generated html is <input type="text" id="txtID" name="txtID" value="100"> Still the value is not displaying in the textbox

    – Andy
    Mar 25 at 23:05












  • see this example (dotnetfiddle.net/Pyk2db)

    – Ajeet Kumar
    Mar 26 at 3:36











  • Thank you Ajeet Kumar. your example is perfect, but still the value is not visible in the TextBox. The generated HTML is same, still the value is not being assigned to the textbox.

    – Andy
    Mar 26 at 7:53













0












0








0








I have a search functionality in the Index page with search options that results in Grid with Details link(another page), I am redirecting to Details page. From details page to Index page I need to retain the search criteria.



I am using ViewBag to store the values and and able to see the value in the Index.cshtml but the value is not assigned in the TextBox



Controller:



public ActionResult Index(string type)

try

if (type == "Search")

ViewBag.Id = 100;
return View();


catch (Exception ex)

ViewBag.ErrorMessage = "An error occurred: " + ex.Message;
return View();




Index.cshtml:



@Html.TextBox("txtID", (string)ViewBag.Id, new id = "txtID", @class = "input" )


Generated HTML:



<input class="inputBox" id="txtID" name="txtID" type="text" value="100">


The generated output is having the value as 100, but the value is not assigned to the Textbox and it is displaying Empty/Null.



How to assign the ViewBag value to @HTML.TextBox










share|improve this question
















I have a search functionality in the Index page with search options that results in Grid with Details link(another page), I am redirecting to Details page. From details page to Index page I need to retain the search criteria.



I am using ViewBag to store the values and and able to see the value in the Index.cshtml but the value is not assigned in the TextBox



Controller:



public ActionResult Index(string type)

try

if (type == "Search")

ViewBag.Id = 100;
return View();


catch (Exception ex)

ViewBag.ErrorMessage = "An error occurred: " + ex.Message;
return View();




Index.cshtml:



@Html.TextBox("txtID", (string)ViewBag.Id, new id = "txtID", @class = "input" )


Generated HTML:



<input class="inputBox" id="txtID" name="txtID" type="text" value="100">


The generated output is having the value as 100, but the value is not assigned to the Textbox and it is displaying Empty/Null.



How to assign the ViewBag value to @HTML.TextBox







asp.net-mvc






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 22:31









Peter B

14.2k5 gold badges20 silver badges47 bronze badges




14.2k5 gold badges20 silver badges47 bronze badges










asked Mar 25 at 22:11









AndyAndy

11 bronze badge




11 bronze badge












  • I have used the suggested above and the generated html is <input type="text" id="txtID" name="txtID" value="100"> Still the value is not displaying in the textbox

    – Andy
    Mar 25 at 23:05












  • see this example (dotnetfiddle.net/Pyk2db)

    – Ajeet Kumar
    Mar 26 at 3:36











  • Thank you Ajeet Kumar. your example is perfect, but still the value is not visible in the TextBox. The generated HTML is same, still the value is not being assigned to the textbox.

    – Andy
    Mar 26 at 7:53

















  • I have used the suggested above and the generated html is <input type="text" id="txtID" name="txtID" value="100"> Still the value is not displaying in the textbox

    – Andy
    Mar 25 at 23:05












  • see this example (dotnetfiddle.net/Pyk2db)

    – Ajeet Kumar
    Mar 26 at 3:36











  • Thank you Ajeet Kumar. your example is perfect, but still the value is not visible in the TextBox. The generated HTML is same, still the value is not being assigned to the textbox.

    – Andy
    Mar 26 at 7:53
















I have used the suggested above and the generated html is <input type="text" id="txtID" name="txtID" value="100"> Still the value is not displaying in the textbox

– Andy
Mar 25 at 23:05






I have used the suggested above and the generated html is <input type="text" id="txtID" name="txtID" value="100"> Still the value is not displaying in the textbox

– Andy
Mar 25 at 23:05














see this example (dotnetfiddle.net/Pyk2db)

– Ajeet Kumar
Mar 26 at 3:36





see this example (dotnetfiddle.net/Pyk2db)

– Ajeet Kumar
Mar 26 at 3:36













Thank you Ajeet Kumar. your example is perfect, but still the value is not visible in the TextBox. The generated HTML is same, still the value is not being assigned to the textbox.

– Andy
Mar 26 at 7:53





Thank you Ajeet Kumar. your example is perfect, but still the value is not visible in the TextBox. The generated HTML is same, still the value is not being assigned to the textbox.

– Andy
Mar 26 at 7:53












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347153%2fpass-value-from-controller-to-html-textbox%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347153%2fpass-value-from-controller-to-html-textbox%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현