title: Passing prompt box value from javascript function- PostBack to c#
body: <p>I'll try to do the best I can to articulate what I'm trying to do.</p>
  
  <p>Let me preface by saying that I am very new to C# and ASP.NET and have minimal experience with javascript.</p>
  
  <p>I have a javascript function that invokes a prompt box. The overall picture is - if input is entered  - it will be saved to a column in the database.  </p>
  
  <p>I'm drawing a blank on passing the value from the prompt box to the PostBack in c#.</p>
  
  <pre><code>function newName()
  {
      var nName = prompt("New Name", " ");
      if (nName != null)
      {
          if (nName == " ")
          {
              alert("You have to specify the new name.");
              return false;
          }
          else
          {
              // i think i need to getElementByID here???
              //document.forms[0].submit();
          }
      }
  }
  </code></pre>
  
  <p>This is what I have in C#:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      if (!IsPostBack)
      {
          //I have other code that works here
      }
      else
      {
          //I'm totally lost here
      }
  }
  </code></pre>
  
  <p>I'm trying to figure out how to make that call for the input from the javascript function.</p>
  
  <p>I've spent the last few hours looking online and in books. Been overwhelmed.</p>
  
  <p>EDIT</p>
  
  <p>i did a little tweeking to fit what I'm trying to do.... </p>
  
  <pre><code>&lt;asp:HiddenField ID="txtAction" runat="server" Value="" /&gt; 
  
  document.forms(0).txtAction.Value = "saveevent"; 
  document.forms(0).submit();
  </code></pre>
  
  <p>trying to figure out how to insert the string into the table now..... </p>
  
  <pre><code> string nEvent = Request.Form["event"]; 
      if (txtAction.Value == "saveevent") { 
                     nName.Insert(); //am i on the right track? 
                   }
  </code></pre>