I have a web form in which I am using a textbox control with multiline property and below this control I am using a label control. I want that whatever I type in my textbox after every entry the text in label control gets appended with the text I have given as input. This is my aspx page-
<table border="1">
<tr>
<td>Content:</td>
<td>
<asp:TextBox ID="txtdetails" runat="server" TextMode="MultiLine" Height="101px" Width="328px"></asp:TextBox><br />
<asp:Label ID="lblsource" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="btnsub" runat="server" Text="Submit" onclick="btnsub_Click" />
</td>
</tr>
</table>
This is my cs page-
protected void btnsub_Click(object sender, EventArgs e)
{
try
{
if (txtdetails.Text != "")
{
txtdetails.Text = txtdetails.Text.Replace(System.Environment.NewLine, "<br>");
maxid = g1.generate_max_reg_id("select max(id) from tbl_content");
rows = g1.ExecDB("insert into tbl_content values(" + maxid + ",'" + txtdetails.Text.ToString() + string.Format("{0}<strong>MyName</strong>", lblsource.Text)+"')");
txtdetails.Text = string.Empty;
}
if (rows > 0)
{
ClientScript.RegisterStartupScript(typeof(Page), "AlertMessage", "alert('Successful!!!');window.location='textare_append.aspx';", true);
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
I am getting a SQL exception in insert query. Please guide where I am doing wrong?
protected void btnsub_Click(object sender, EventArgs e)
{
try
{
if (txtdetails.Text != "")
{
lblsource.Text=lblsource.Text+ txtdetails.Text;
txtdetails.Text = txtdetails.Text.Replace(System.Environment.NewLine, "<br>");
maxid = g1.generate_max_reg_id("select max(id) from tbl_content");
rows = g1.ExecDB("insert into tbl_content values(" + maxid + ",'" + txtdetails.Text.ToString() + string.Format("{0}<strong>MyName</strong>", lblsource.Text)+"')");
txtdetails.Text = string.Empty;
}
if (rows > 0)
{
ClientScript.RegisterStartupScript(typeof(Page), "AlertMessage", "alert('Successful!!!');window.location='textare_append.aspx';", true);
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}