title: Change Literal text on usercontrol VB.Net
body: <p>Good day</p>
  
  <p>I have a VB.Net project. 
  My main page is Display.aspx
  I have various usercontrols (ascx) that use this page.
  On one of these controls, I have a Literal, lblCatQuestion.
  In the code behind of the control</p>
  
  <pre><code> Protected WithEvents lblCatQuestion As Literal
  </code></pre>
  
  <p>What this literal basically does is it loads up with some text and radio buttons. When clicking on the radio buttons, a Jquery form pops up. Upon completing the form and saving and closing, this literal should now display a message.
  The message comes from the main Display page's code behind</p>
  
  <p>For purposes here, on the Display.aspx.vb</p>
  
  <pre><code> Session("CatMessage") = "Completed"
      Dim label As System.Web.UI.WebControls.Literal = New System.Web.UI.WebControls.Literal
      label = DirectCast(Page.FindControl("lblCatQuestion"), System.Web.UI.WebControls.Literal).Text = Session("CatMessage")
  </code></pre>
  
  <p>Problem is, when I debug, I always get a nullreferenceexception when trying to assign the text to the literal. 
  When I look, the page here is described as </p>
  
  <blockquote>
    <p>display_aspx
    <a href="https://i.stack.imgur.com/bXZVX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bXZVX.png" alt="enter image description here"></a></p>
  </blockquote>
  
  <p>but on my url, the page is </p>
  
  <blockquote>
    <p>Display.aspx?pid=4</p>
  </blockquote>
  
  <p>Could this be cauing the nullreferenceexception? As the page is not exactly Display.aspx anymore, but Display.aspx?pid=4
  <a href="https://i.stack.imgur.com/r0imC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r0imC.png" alt="enter image description here"></a></p>
  
  <p>How would I change the literal's text now?
  How would I get the exact page, so that I can change the text value?</p>
  
  <p>Thanks for the help</p>
  
  <p>EDIT</p>
  
  <p>This is declared in the control's code behind</p>
  
  <pre><code> If Not Session("CatMessage") Is Nothing Then
              lblCatQuestion.Text = Session("CatMessage")
          End If
  </code></pre>
  
  <p>But the text does not change. Hence why I'm looking into a different method</p>