.NET .Newbie

Results 1 to 4 of 4

Thread: .NET .Newbie

  1. #1
    Join Date
    Dec 1969
    Posts
    213

    Default .NET .Newbie

    I&#039;ve been coding in ASP for several years and am just now starting to learn ASP.NET. I&#039;m having some trouble with the &#060;asp:Literal&#062; control and was wondering if it&#039;s something I&#039;m not doing right, or if this is just the way .NET works.<BR><BR>Anyway, the situation is that I have an &#060;asp:Literal&#062; item on my page, and then after that I call a function which is supposed to set the Text property of the Literal control. Unfortunately, this doesn&#039;t work. If I moved the function call so that it appears before the Literal control, then the text gets set properly.<BR><BR>Here is a simplified version of what I&#039;m doing:<BR><BR>&#060;script runat="server"&#062;<BR>Sub Something<BR>&nbsp;&nbsp;&nbsp;&nbsp;Literal1.Text = "Hello, world!"<BR>End Sub<BR>&#060;/script&#062;<BR><BR>...<BR><BR>&#060;asp:Literal id="Literal1" runat="server"&#062;&#060;/asp:Literal&#062;<BR><BR>...<BR><BR>&#060;%<BR>Som ething()<BR>%&#062;<BR><BR>This code doesn&#039;t work, but if I move the call to Something so that it appears before the &#060;asp:Literal&#062; control definition, then it works okay.

  2. #2
    Join Date
    Dec 1969
    Posts
    276

    Default RE: .NET .Newbie

    my guess is it has to do with the processing order of the page...<BR>and the render block that calls the function could not change the text that has already been passed to the headers...<BR><BR>.net is a little different from asp...you will hardly ever use render blocks &#060;%%&#062; outside of the script tag, except for placing data from a db...what you probably want to do is this routine...<BR><BR>Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<BR> Something() <BR>End Sub<BR><BR>Just place that inside your script tag and it will run on the page load.

  3. #3
    Join Date
    Dec 1969
    Posts
    213

    Default RE: .NET .Newbie

    Thanks, phreaker. It&#039;s going to take a little getting used to doing things the "new" way, although ultimately I think it will be better (cleaner, at least).

  4. #4
    Join Date
    Dec 1969
    Posts
    655

    Default RE: .NET .Newbie

    Or the simple version<BR><BR>sub Page_Load()<BR>&nbsp;&nbsp;Something()<BR>end sub


Posting Permissions

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