Results 1 to 11 of 11

Thread: text box text wont change

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    text box text wont change

    i have a asp.net page that has some text boxes with some text in there..then i have a submit button..the problem is that when i try in code to get what the textboxes have in the .Text property i get what i've put when the page loaded and not what actually the user has written! anyone has experienced this? what am i doing wrong?

    help!!!!!!!!!!!!!
    \m/\m/

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    You just not checking for post back...like I said in the other thread, post your code (especially your load event code) and I will show you how to use it properly to ensure things like this don't happen.

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    load event
    Code:
    WebMessage web = Serializer.BinDeSerializer(Server.MapPath(@"Logs\" + Request.QueryString["File"]));
    msgTxt.Text = web.Message;
    titleTxt.Text = web.Title;
    nickTxt.Text = web.Author;
    \m/\m/

  4. #4

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    post(edit)button
    Code:
    case "EDIT": {
    	Debug.WriteLine(titleTxt.Text);
    	string filename = Server.MapPath(@"Logs\" + Request.QueryString["File"]);
    	WebMessage oldMsg = Serializer.BinDeSerializer(filename);
    
    	if (File.Exists(filename)) {
    		File.Delete(filename);
    	}
    
    	WebMessage newMsg = new WebMessage(
    		titleTxt.Text,
    		msgTxt.Text,
    		nickTxt.Text,
    		DateTime.Now,
    		oldMsg.Comments,
    		Path.GetFileName(filename));
    
    	Serializer.BinSerialize(newMsg, filename);
    	Response.Redirect("Log.aspx?&Action=POST", true);
    	break;
    where titleTxt,msgTxt,nickTxt are the TextBoxes which arent changing the text
    \m/\m/

  5. #5
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    In your page load event, check for Page.IsPostBack.

    Code:
    if (!Page.IsPostBack) {
       // Perform your initialization (db calls, etc..)
    }

  6. #6

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    still not working...i dont get what would help checkin if it is postback or not lol..because if it is postback and now is not working then checking for it wont help, if it isnt and isnt working by checking i will not do it work..so *** can i do?
    \m/\m/

  7. #7
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Because we are working in a stateless environment. Everytime a postback occurs, the page_load event fires off before any of the control event(s) that caused the post back. So, if you reset the values in the load event, then in your event handler, you are still dealing with the initial default values.

  8. #8
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Change to this:
    Code:
    if (!Page.IsPostBack) 
    {
       WebMessage web = Serializer.BinDeSerializer(Server.MapPath(@"Logs\" + Request.QueryString["File"]));
       msgTxt.Text = web.Message;
       titleTxt.Text = web.Title;
       nickTxt.Text = web.Author;
    }

  9. #9

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    hmm....even with hellswraith code it doesnt work..
    \m/\m/

  10. #10
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Well, the code I posted is the exact same, so it wouldn't work (minus the three lines of code)

    Post your entire code-behind, it's something else..

  11. #11

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    hmm my page is getting a bit confusing, since its only my 2nd asp.net project and i wasnt expecting for somethings i had to implement..i will make a new architecture for the site and then i will try again and if it doesnt work post it here again..but i need to implement cookies..anyone could answer by other post about cookies plz?

    tks by ur answers btw
    \m/\m/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width