Note that there are some explanatory texts on larger screens.

plurals
  1. PORazor / Webmatrix / SQL: Update Textarea
    primarykey
    data
    text
    <p>I am trying to implement an short bio form where each user could edit and update its bio. Based on the fact that if the user has filled the form before or not, the previous text or nothing, gets returned as an initial text in the Textarea.</p> <p>Here is the block I have for taking the username from the keyboard, searching the dbase for a value and <em>trying</em> to output it on the textarea before the form gets submitted by the user.</p> <p>A kind of profile memory if you like.</p> <pre><code>@{ Validation.RequireField("currentuser"); Validation.Add("bioprint", Validator.StringLength(3000, 0, "Your bio should not exceed 3000 characters")); var init = ""; var currentuser = Request["currentuser"]; var db = Database.Open("ResearchA"); var cbio = db.QuerySingle("SELECT bios FROM usernamesb WHERE username = @0",currentuser); //get current bio string if (cbio == null) {init = cbio;} //check if string is NULL else {init = "Tell us about you...";} if(IsPost &amp;&amp; Validation.IsValid()) { var userbio = @Request["Bio"]; var insertbio = "UPDATE usernamesb SET bios = @0 WHERE username = @1"; db.Execute(insertbio, userbio, currentuser); //Update database with a new entry. } </code></pre> <p>}</p> <p>And here is how I have my controls setup in the HTML block:</p> <pre><code>&lt;input type="text" name="currentuser" id="currentuser" value="@Request.Form["currentuser"]"/&gt; &lt;textarea name="Bio" rows="10" cols="50" placeholder ="@cbio"&gt;&lt;/textarea&gt; </code></pre> <p>However I dont get the already existing string output. </p> <p>Thanks a lot for the interest guys!!</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. 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