How to add ID and Name property to Html.BeginForm() in asp.net mvc?

Jacob
Jacob
34 Points
17 Posts

Hi

I am using Html.BeginForm() as:

 

@using (Html.BeginForm("FAQ", "Default1",FormMethod.Post))
{
<div class="col-md-10">
<h1>Query Form </h1>
<input class="footer-input" name="fnameFAQ" value="Name" onfocus="if (this.value == 'Name') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Name';}">
<input class="footer-input" name="profession" value="Profession" onfocus="if (this.value == 'Profession') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Profession';}">
<input class="footer-input" name="emailFAQ" value="Email" onfocus="if (this.value == 'Email') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Email';}">
<input class="footer-input footer-input-mr" name="phoneFAQ" value="Phone No." onfocus="if (this.value == 'Phone No.') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Phone No.';}">
<textarea class="footer-txt-area" name="taFAQ" value="Queries" onfocus="if (this.value == 'Queries') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Queries';}">Queries</textarea>
</div>
<div class="col-md-2">
<div class="form-button">
<button type="submit" name="Command" value="FAQSave" class="footer-button">Submit</button>
</div>
</div>
}

 

I want to add ID and Name of form tag.

Views: 8663
Total Answered: 3
Total Marked As Answer: 1
Posted On: 04-Sep-2015 00:44

Share:   fb twitter linkedin
Answers
avnish
avnish
Participant
84 Points
27 Posts
         

Try this Jacob bhai..

Html.BeginForm("FAQ", "Default1",FormMethod.Post,new { id = "signupform" }
Posted On: 04-Sep-2015 09:41
Jacob
Jacob
34 Points
17 Posts
         

Hi Avnish,

It's working fine.

Thanks

Posted On: 04-Sep-2015 22:34
andro
andro
16 Points
8 Posts
         

Use following:

@using (Html.BeginForm("FAQ", "Default1",FormMethod.Post,new { id = "signupform" })
{
<div class="col-md-10">
<h1>Query Form </h1>
<input class="footer-input" name="fnameFAQ" value="Name" onfocus="if (this.value == 'Name') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Name';}">
<input class="footer-input" name="profession" value="Profession" onfocus="if (this.value == 'Profession') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Profession';}">
<input class="footer-input" name="emailFAQ" value="Email" onfocus="if (this.value == 'Email') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Email';}">
<input class="footer-input footer-input-mr" name="phoneFAQ" value="Phone No." onfocus="if (this.value == 'Phone No.') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Phone No.';}">
<textarea class="footer-txt-area" name="taFAQ" value="Queries" onfocus="if (this.value == 'Queries') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Queries';}">Queries</textarea>
</div>
<div class="col-md-2">
<div class="form-button">
<button type="submit" name="Command" value="FAQSave" class="footer-button">Submit</button>
</div>
</div>
}
Posted On: 10-May-2018 20:25
 Log In to Chat