Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. solution to PostBack? [modified]

solution to PostBack? [modified]

Scheduled Pinned Locked Moved ASP.NET
helpquestion
11 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    blurMember
    wrote on last edited by
    #1

    There was an error message System.NullReferenceException was unhandled by user code Message="Object reference not set to an instance of an object.". Here is my code. Is there anything wrong? I have already set the PostBackUrl button from the previous page. if (!Page.IsPostBack) { TextBox t = (TextBox)PreviousPage.FindControl("txtStartDate"); lblStartDate.Text = t.Text; } -- modified at 0:06 Monday 7th August, 2006

    thanks in advance. Much appreciated.

    L J I 3 Replies Last reply
    0
    • B blurMember

      There was an error message System.NullReferenceException was unhandled by user code Message="Object reference not set to an instance of an object.". Here is my code. Is there anything wrong? I have already set the PostBackUrl button from the previous page. if (!Page.IsPostBack) { TextBox t = (TextBox)PreviousPage.FindControl("txtStartDate"); lblStartDate.Text = t.Text; } -- modified at 0:06 Monday 7th August, 2006

      thanks in advance. Much appreciated.

      L Offline
      L Offline
      l0kke
      wrote on last edited by
      #2

      I suppose you don't have txtStartDate textbox on your page, thats why this exception is raised. Pilo

      B 1 Reply Last reply
      0
      • B blurMember

        There was an error message System.NullReferenceException was unhandled by user code Message="Object reference not set to an instance of an object.". Here is my code. Is there anything wrong? I have already set the PostBackUrl button from the previous page. if (!Page.IsPostBack) { TextBox t = (TextBox)PreviousPage.FindControl("txtStartDate"); lblStartDate.Text = t.Text; } -- modified at 0:06 Monday 7th August, 2006

        thanks in advance. Much appreciated.

        J Offline
        J Offline
        jitu gupta
        wrote on last edited by
        #3

        hi, i think you are not giving the currect textbox name or textbox is not present check the textbox name. thanks

        B 1 Reply Last reply
        0
        • B blurMember

          There was an error message System.NullReferenceException was unhandled by user code Message="Object reference not set to an instance of an object.". Here is my code. Is there anything wrong? I have already set the PostBackUrl button from the previous page. if (!Page.IsPostBack) { TextBox t = (TextBox)PreviousPage.FindControl("txtStartDate"); lblStartDate.Text = t.Text; } -- modified at 0:06 Monday 7th August, 2006

          thanks in advance. Much appreciated.

          I Offline
          I Offline
          IamMohan
          wrote on last edited by
          #4

          Hi, The problem could be, the reference to the page were the textbox(txtStartDate)is available might not be referred. If the textbox has to be referred from the current page were you want the reference you can do so by. if (!Page.IsPostBack) { TextBox t = (TextBox)this.Page.FindControl("txtStartDate"); lblStartDate.Text = t.Text; } Hope this should work Regards:-O

          Mohan

          B 1 Reply Last reply
          0
          • L l0kke

            I suppose you don't have txtStartDate textbox on your page, thats why this exception is raised. Pilo

            B Offline
            B Offline
            blurMember
            wrote on last edited by
            #5

            i have that textbox obviously. :(

            thanks in advance. Much appreciated.

            L 1 Reply Last reply
            0
            • J jitu gupta

              hi, i think you are not giving the currect textbox name or textbox is not present check the textbox name. thanks

              B Offline
              B Offline
              blurMember
              wrote on last edited by
              #6

              thanks. i checked many times, but it seems i type correctly, or rather copy paste correctly.:->

              thanks in advance. Much appreciated.

              1 Reply Last reply
              0
              • I IamMohan

                Hi, The problem could be, the reference to the page were the textbox(txtStartDate)is available might not be referred. If the textbox has to be referred from the current page were you want the reference you can do so by. if (!Page.IsPostBack) { TextBox t = (TextBox)this.Page.FindControl("txtStartDate"); lblStartDate.Text = t.Text; } Hope this should work Regards:-O

                Mohan

                B Offline
                B Offline
                blurMember
                wrote on last edited by
                #7

                I tried and I faced same error. I should be clearer with the error. It says: if (!Page.IsPostBack) { TextBox t = (TextBox)this.Page.FindControl("txtStartDate"); lblStartDate.Text = t.Text; } lblStartDate.Text = t.Text; The error stops at this line saying "Object reference not set to an instance of an object." The troubleshooting tips were: Use the "new" keyword to create an object instance. Check to determine if the object is null before calling the method.

                thanks in advance. Much appreciated.

                B 1 Reply Last reply
                0
                • B blurMember

                  I tried and I faced same error. I should be clearer with the error. It says: if (!Page.IsPostBack) { TextBox t = (TextBox)this.Page.FindControl("txtStartDate"); lblStartDate.Text = t.Text; } lblStartDate.Text = t.Text; The error stops at this line saying "Object reference not set to an instance of an object." The troubleshooting tips were: Use the "new" keyword to create an object instance. Check to determine if the object is null before calling the method.

                  thanks in advance. Much appreciated.

                  B Offline
                  B Offline
                  blurMember
                  wrote on last edited by
                  #8

                  I hope my MS visual is not haunted. X|

                  thanks in advance. Much appreciated.

                  I 1 Reply Last reply
                  0
                  • B blurMember

                    I hope my MS visual is not haunted. X|

                    thanks in advance. Much appreciated.

                    I Offline
                    I Offline
                    IamMohan
                    wrote on last edited by
                    #9

                    Is that TextBox is inside any other controls like DataGrid,DataList or Panel. The reason for the Problem could be: 1) If the TextBox(txtxStartDate) is not available in the respective page. 2) If the page reference is not set when calling this.Page.FindControl 3) If the TextBox is inside some other controls like DataGrid,DataList or Panel. Please do check and come around.:-O

                    P. Mohan

                    B 1 Reply Last reply
                    0
                    • B blurMember

                      i have that textbox obviously. :(

                      thanks in advance. Much appreciated.

                      L Offline
                      L Offline
                      l0kke
                      wrote on last edited by
                      #10

                      In this case, if you really want people to help you to solve this problem, you should copy - paste your code. if you declare this TextBox in aspx file, then paste it here (at least relevant part), if you create it dynamicaly, paste here code where you do so. There is a possibility, that problem is with lblStartDate. Try to debug your application and check each value, you will see if FindControls returns your desired textBox and if lblStartDate is not null. Pilo

                      1 Reply Last reply
                      0
                      • I IamMohan

                        Is that TextBox is inside any other controls like DataGrid,DataList or Panel. The reason for the Problem could be: 1) If the TextBox(txtxStartDate) is not available in the respective page. 2) If the page reference is not set when calling this.Page.FindControl 3) If the TextBox is inside some other controls like DataGrid,DataList or Panel. Please do check and come around.:-O

                        P. Mohan

                        B Offline
                        B Offline
                        blurMember
                        wrote on last edited by
                        #11

                        I am using MaterPages + .NET 2.0 Login Control. I observed that if my webform had not used the MasterPages or the webform was not autheticated by the Login Control, the postback will work fine. Is there a diferent code?

                        thanks in advance. Much appreciated.

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups