How to change value of TextBox before inserting it into database by FormParameter?
Here is test script. I would like to create script which add "ok" to value of TextBox with ID="name_pl" and then insert it to database using FromParameter. For example, when I write "let" in TextBox and click "Submit", script insert to database "letok". How to do this? I have tried to do this by adding name_pl = name_pl + "ok"; before links.Insert(); but this cause error "CS0029: Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.TextBox'".
Could you help me? Test script:
<%
@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml" ><head><title>Untitled Page</title><link href="../format.css" rel="stylesheet" type="text/css" />
<
script type="text/c#" runat="server">public void submit_click(object source, EventArgs e)
{
name_pl = name_pl + "ok";
links.Insert();
}
</
script> </head>
<
body>
<div>
<form id="form" runat="server" action="Request.ServerVariables['SCRIPT_NAME'];" defaultbutton="submit">
<p>
<strong>Text:</strong>
<asp:TextBox ID="name_pl" runat="server" AutoPostBack="true" Width="300px"></asp:TextBox>
</p>
<p><asp:Button ID="submit" runat="server" OnClick="submit_click" Text="Submit" /></p>
</form>
<asp:AccessDataSource ID="links" DataFile="~/App_Data/data.mdb" runat="server" InsertCommand="INSERT Into links (name_pl) Values (@name_pl)">
<InsertParameters>
<asp:FormParameter FormField="name_pl" Name="name_pl" />
</InsertParameters>
</asp:AccessDataSource>
</div>
</body>
</
html>
I am asking for help politely.