ASP.NET MVC : Get text Box input in a controller action method -



ASP.NET MVC : Get text Box input in a controller action method -

i have 2 2 textboxes in page , button. when user clicks button want pass text entered user in action method of controller. might silly. new mvc. pls tell me how this. here code have tried.

view

<input type="text" name="input_domain_id" class="form-control text-center" placeholder="domain id" autofocus required> <input type="password" name="input_domain_password" class="form-control text-center" placeholder="domain password" required> <div class="col-lg-12"> <p><button class="btn btn-lg btn-success btn-block" type="submit" onclick="location.href='@url.action("verifylogin", "ldaploginverify")'">login</button></p> </div>

and in controller

public actionresult verifylogin(string input_domain_id, string input_domain_password) { return(view); }

in code getting null values in both parameters. pls tell me how this.p

you need html form. best way utilize mvc helper:

@using (html.beginform()) { <input type="text" name="input_domain_id" class="form-control text-center" placeholder="domain id" autofocus required> <input type="password" name="input_domain_password" class="form-control text-center" placeholder="domain password" required> <div class="col-lg-12"> <p><button class="btn btn-lg btn-success btn-block" type="submit" onclick="location.href='@url.action("verifylogin", "ldaploginverify")'">login</button></p> </div> }

you want create sure have 2 actions.

[httpget] public actionresult verifylogin() { homecoming view(/* optional model prepopulated info */); } [httppost] public actionresult verifylogin(string input_domain_id, string input_domain_password) { // stuff posted values... homecoming view(); }

you should using helpers inputs, buttons, etc...

@html.editorfor(), @html.passwqordfor, etc.

asp.net-mvc model-view-controller asp.net-mvc-5

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -