c# - How to pass variable from textbox to code behind back to same page -


I have a JAX form page and I have a text box that is clicked once and a code Passes the variable and then back to the second element of that page and I can not get it to work. This is the closest I got.

  & asp: panel id = "search" runat = "server" view = "correct" & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; asp: label id = "lbl search" run = "server" text = "search" & gt; & Lt; / Asp: label & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; ASP: Text Box ID = "Search" Runat = "Server" /> & Lt; / TD & gt; & Lt; TD & gt; & Lt; Asp: RequiredFieldValidator id = "valSearch" runat = "server" ControlToValidate = "movieSearch" text = "please enter text" /> & Lt; / TD & gt; & Lt; TD & gt; & Lt; ASP: Button ID = "BTSS submit" runat = "server" text = "save" onclic = "btnbmitilik" /> & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / ASP: Cell & gt; & Lt; asp: panel id = "pnlSearchResult" runat = "server" view = "wrong" & gt; & Lt; Script & gt; Var Search = '& lt;% = Server.UrlDecode (Request.JQueryString ["Data"])% & gt;'; & Lt; / Script & gt; & Lt; / ASP: Cell & gt;   

and the rear code:

  Secure Zero btnSubmit_Click (Object Sender, EventArgs e) {if (Valid) Isvalid {pnlSearch.Visible = false; PnlSearchResult.Visible = true; Response.Redirect ("search.aspx? Data =" + Server.UrlEncode (search .text)); }}   

In addition to this it does not change the visibility of the two panels for some reason.

I appreciate any guidance I am very new to ASP and C # I

The visibility of the panel is not changing because you are forcing a new GET request for the page at: -

  feedback. Redirect ("search.aspx? Data =" + server.URLNcode (search. Text));   

(I assume that your page is called 'search.aspx')

Remove this line, there is no need to do this.

Secondly, I think you want to emphasize the text value of the textbox in a JavaScript variable. Change it to

  var search = '& lt;% = Server.UrlDecode (Request .JQueryString ["Data"])% & gt;';   

with this

  var search = '& lt;% = search.Text% & gt;';    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -