English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm creating a simple add-link page. When i click "New link" the page gets redirected to itself (a la classic asp) Links.aspx?action=edit&linkid=3 . Now when the page reloads i fill my input fields with the according data from SQL db at runtime. But then when i try to change this input it still saves the originally loaded content. When i don't load the content in t he fields first it does work. Anyone have a clue?

2007-02-28 01:44:57 · 2 answers · asked by rystest 2 in Computers & Internet Programming & Design

2 answers

What is probably happening is you are not taking postbacks into account correctly. You are loading the content into the text box, then when you submit the form, you are loading the content again, which will overwrite anything you've typed into the box. Make sure you are only loading the data from SQL the first time around - if you are doing it in Page_Load (or another page cycle event handler), wrap the code in an if(!IsPostBack) statement. It would be easier to debug if you posted the code, however.

2007-02-28 01:56:48 · answer #1 · answered by Rex M 6 · 0 1

That's probably because you don't have a conditional IsPostBack check in your Page_Load event handler. When you click a button that posts back, the Page_Load gets called before the button's event handler, so Page_Load is putting back the original value into the control instead of using the new one. You need something like this in Page_Load:

if(!IsPostBack)
{

}

2007-02-28 10:19:52 · answer #2 · answered by Raymond 3 · 0 1

fedest.com, questions and answers