Answered by:
How to write HTML page button click method in .CS

Question
-
User1522868016 posted
Hi Experts,
I am using HTML page for designing a website. I have a user registration form and a Register button.
Here my complication is how to write method for the Register button click event.Please suggest below is my html tag for button.
<tr>
<td>
<input type="button" name="btnSubmit" id="btnSubmit" value="Register Now" onclick="RegisterProcess" />
</td></tr>
Thursday, June 27, 2019 6:27 AM
Answers
-
User665608656 posted
Hi sreedhardax,
According to your description, if you want to use server controls (that is, similar to the button I gave you), you just need to create a webform project using Visual Studio software to use these controls directly.
Here is the download link: https://visual studio.microsoft.com/downloads/
You can learn the asp.net web server control from this link: http://w3schools.sinsixx.com/aspnet/aspnet_refwebcontrols.asp.htm
Of course, you can still use your original HTML to achieve your functions.
Best Regards,
YongQing.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, June 28, 2019 3:33 AM
All replies
-
User-1038772411 posted
Hello sreedhardax,
I recommend you to refer the following links
Based on your requirement if you want to call server side function you have to refer below
https://stackoverflow.com/questions/7189037/calling-server-side-event-from-html-button-control
If you want to create simple registration form using asp.net
Kindly refer the following example
https://www.c-sharpcorner.com/blogs/creating-a-simple-registration-form-in-asp-net
I hope this will help you
Thank you.
Thursday, June 27, 2019 7:03 AM -
User1522868016 posted
Hi,
Thanks for the suggestion here I am using HTML page for design. I have wrote the same HTML tag for submit button as below
<tr>
<td>
<input type="submit" id="btnSubmit" value="Register Now" runat="server" onserverclick="btnSubmit_Click" />
</td></tr>
And here is my .CS code below is the way what I am doing is correct?? Please suggest
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.Sql;
namespace InsuranceDemoV1
{
public class UserRegistration
{
public void btnSubmit_Click(object sender,EventArgs e)
{
}
}}
Thursday, June 27, 2019 7:10 AM -
User665608656 posted
Hi sreedhardax,
Yes, you're absolutely right to do that.
You can also use Button control to achieve this function like below:
<asp:Button ID="Button1" runat="server" Text="Register Now" OnClick="Button1_Click" />
For more details, you could refer to this link : https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.button?view=netframework-4.8
Best Regards,
YongQing.
Thursday, June 27, 2019 7:30 AM -
User1522868016 posted
Hi YongQing,
Actually I am designing website completely through HTML only. Do we have any provision to achieve the same flow that you have mentioned in your reply with HTML website??
Thursday, June 27, 2019 8:12 AM -
User665608656 posted
Hi sreedhardax,
According to your description, if you want to use server controls (that is, similar to the button I gave you), you just need to create a webform project using Visual Studio software to use these controls directly.
Here is the download link: https://visual studio.microsoft.com/downloads/
You can learn the asp.net web server control from this link: http://w3schools.sinsixx.com/aspnet/aspnet_refwebcontrols.asp.htm
Of course, you can still use your original HTML to achieve your functions.
Best Regards,
YongQing.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, June 28, 2019 3:33 AM