Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have add a form that call the FormParameter.aspx. This can not work like that, manually.</p> <p>So keep one form only and place there all the controls, and there the post back will work correctly.</p> <pre><code>&lt;form id="form1" runat="server"&gt; &lt;label &gt;Title :&lt;/label&gt; &lt;input id="txtTitle" type="text" /&gt;&lt;br /&gt; &lt;label &gt;Subject:&lt;/label&gt; &lt;input id="txtSubject" type="text" /&gt;&lt;br /&gt; &lt;label &gt;Category: &lt;/label&gt; &lt;input id="txtCategory" type="text" /&gt;&lt;br /&gt; &lt;input id="btnAdd" type="submit" value="Add" /&gt; &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;%$ ConnectionStrings:MessagesConnectionString %&gt;" InsertCommand="INSERT INTO [Messages] ([Title], [Subject], [CategoryID]) VALUES (@Title, @Subject, @CategoryID)" SelectCommand="SELECT * FROM [Messages]" &gt; &lt;InsertParameters&gt; &lt;asp:FormParameter Name="Title" FormField="txtTitle" DefaultValue="No Title" /&gt; &lt;asp:FormParameter Name="Subject" FormField="txtSubject" DefaultValue="No Subject" /&gt; &lt;asp:FormParameter Name="CategoryID" FormField="txtCategory" DefaultValue="No Category" /&gt; &lt;/InsertParameters&gt; &lt;/asp:SqlDataSource&gt; &lt;/form&gt; </code></pre> <p>and on code behind is better to use</p> <pre><code>void Page_Load() { if (IsPostBack) SqlDataSource1.Insert(); } </code></pre> <p>There is a way to make your code work, by disable the validation for this page, but you make then your page vulnerable to attacks.</p> <p>Now I see again your code and I am not so sure that InsertParametres can get the values of non server controls, I think that you also need to change them to ServerControls.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload