Click here to Skip to main content
15,868,340 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to pass html textbox value to asp.net textbox and how to save it on mysql database????

below code is for html textbox and button i need to save this textbox value to mysql database
HTML
<input type="visible" name="amount" value="" />
<input type="image" name="submit" 
                            src="http://images.paypal.com/images/x-click-butcc.gif" border="0" 
                            alt="Make payments with PayPal, it's fast, free, and secure!" 
                            style="width: 147px; height: 52px;" />

here i need to pass html textbox value to asp.net textbox and using ap.net button click i need to save the textbox value to database..below code is asp.net textbox....
ASP.NET
<asp:TextBox ID="TextBox49" runat="server">
<asp:Button ID="Button17" runat="server" Text="Button" />
Posted
Updated 30-Sep-12 21:49pm
v2

if u r using html text and button inside aspx page then u should try like this ;

XML
<input id="customerPhone" name="customerPhone" type="Text" />
<button OnServerClick=" Btn_Click" runat="server" id="Button1" />


// In .cs code write

C#
protected void Btn_Click(object sender, EventArgs e)
 {
     string n = String.Format("{0}", Request.Form["customerPhone"]);

 }
 
Share this answer
 
Comments
ANOOP CL NAIR 1-Oct-12 4:16am    
thanks for ur reply again.... i did like this

<input id="amount" name="amount" value="" />

on button click

protected void Btn_Click(object sender, EventArgs e)
{
string n = String.Format("{0}", Request.Form["amount"]);
TextBox1.Text = n;



}


but its not displaying value on textbox1
solanki.net 1-Oct-12 5:17am    
Because here <input id="amount" name="amount" value="" /> u did not set type
i mean u should write like that :

<input id="amount" name="amount" type="text" value="" />


add runat="server" in your html text and assign htmltextbox.value=textbox.text;

when you add runat="server" in html tag, You can access that tag on codebehind page.
to accesss html textbox value you have to write htmltextbox.value="";
 
Share this answer
 
v2
Comments
ANOOP CL NAIR 1-Oct-12 6:37am    
i gave runat="server" in html text code...but its showing error....

i have html textbox and button....i need to save textbox value to mysql database......
can u explain when u want to get html text value in asp.net text ?
 
Share this answer
 
Comments
ANOOP CL NAIR 1-Oct-12 1:31am    
Thanks for ur replay....i have html textbox and button....i need to save the textbox value to database ...when i click on button....

this is html tetxtbox and button code

<input type="visible" name="amount" value="" />


<input type="image" name="submit"
src="http://images.paypal.com/images/x-click-butcc.gif" border="0"
alt="Make payments with PayPal, it's fast, free, and secure!"
style="width: 147px; height: 52px;" />

i know only in asp.net...dont know in html......

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900