Very basic ASP.NET question

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Very basic ASP.NET question

    I've got some Java experience but no JSP or ASP and am trying to get to grips
    with ASP.NET. I'd appreciate some help on a simple question.

    I have been able to get databinding to work, and can display a string obtained
    from the database on the screen by binding it to a label. However, if I have
    an object instantiated in the page's scope, it seems like there should be an
    easier way to output a string that I obtain from that object. I gather that
    in JSP there was some syntax like:

    <%= myObject.aStringProperty %>

    that would substitute the value of this as a literal in the middle of the
    html. I tried this syntax in ASP.NET with no luck; is there something
    analogous? The reference I'm using (Wrox's "Professional C#") while pretty
    good in many ways is a bit light on detailed ASP examples, and I couldn't find
    anything about this in the ASP tutorials I looked at.

    Thanks for any help.

    Mike

    Mike Christie Guest

  2. Similar Questions and Discussions

    1. Basic FLV question
      Can someone please help me. we wish to stream flv files using Flash Media Server 2. we have installed the program however we are at a loss as to how...
    2. basic 3d question
      Hi, Just a qiuck question....I have created a 3d world and exported it to director. I want to add a basic cube shape I create in 3dstudio max to...
    3. Basic Question
      Hello, I've noticed in some sample code that sometimes people use the @ before a string when concatenating them. Example: string filePath =...
    4. Basic question b/w ASP & ASP .NET
      I would like to know what is the basic difference between ASP and ASP .NET VB AND VB .NET ADO and ADO .NET look forward to your responses
    5. basic css question
      In several of my posts lately, I have made it known that I am nto a huge fan of using newer stuff as opposed to older methods of getting things...
  3. #2

    Default Re: Very basic ASP.NET question

    When you are dealing with data objects, you are not really dealing with a
    string property, more an item of a datatype that may contain a string. Try
    reading this, it explains a lot about databinding and covers the area you
    are asking about with soem useful examples and code.

    [url]http://www.aspalliance.com/aspxtreme/webforms/multi-recordsingle-valuedatabi[/url]
    nding.aspx

    --
    Regards

    John Timney (Microsoft ASP.NET MVP)
    ----------------------------------------------
    <shameless_author_plug>
    Professional .NET for Java Developers with C#
    ISBN:1-861007-91-4
    Professional Windows Forms
    ISBN: 1861005547
    Professional JSP 2nd Edition
    ISBN: 1861004958
    Professional JSP
    ISBN: 1861003625
    Beginning JSP Web Development
    ISBN: 1861002092
    </shameless_author_plug>
    ----------------------------------------------

    "Mike Christie" <mikec@athensgroup.com> wrote in message
    news:VQidneobwe-nhq2iRTvUpQ@giganews.com...
    > I've got some Java experience but no JSP or ASP and am trying to get to
    grips
    > with ASP.NET. I'd appreciate some help on a simple question.
    >
    > I have been able to get databinding to work, and can display a string
    obtained
    > from the database on the screen by binding it to a label. However, if I
    have
    > an object instantiated in the page's scope, it seems like there should be
    an
    > easier way to output a string that I obtain from that object. I gather
    that
    > in JSP there was some syntax like:
    >
    > <%= myObject.aStringProperty %>
    >
    > that would substitute the value of this as a literal in the middle of the
    > html. I tried this syntax in ASP.NET with no luck; is there something
    > analogous? The reference I'm using (Wrox's "Professional C#") while
    pretty
    > good in many ways is a bit light on detailed ASP examples, and I couldn't
    find
    > anything about this in the ASP tutorials I looked at.
    >
    > Thanks for any help.
    >
    > Mike
    >

    John Timney \(Microsoft MVP\) Guest

  4. #3

    Default Re: Very basic ASP.NET question

    Mike

    In your HTML put

    <asp:Label ID="lblID" runat="server"><%# myStrvar %></asp:Label>

    In your Codebehind put in C#

    private void Page_Load(object sender, System.EventArgs e)

    {

    myStrvar = "Hello Universe";

    Page.DataBind(); // you need this

    // Put user code to initialize the page here

    }

    "Mike Christie" <mikec@athensgroup.com> wrote in message
    news:VQidneobwe-nhq2iRTvUpQ@giganews.com...
    > I've got some Java experience but no JSP or ASP and am trying to get to
    grips
    > with ASP.NET. I'd appreciate some help on a simple question.
    >
    > I have been able to get databinding to work, and can display a string
    obtained
    > from the database on the screen by binding it to a label. However, if I
    have
    > an object instantiated in the page's scope, it seems like there should be
    an
    > easier way to output a string that I obtain from that object. I gather
    that
    > in JSP there was some syntax like:
    >
    > <%= myObject.aStringProperty %>
    >
    > that would substitute the value of this as a literal in the middle of the
    > html. I tried this syntax in ASP.NET with no luck; is there something
    > analogous? The reference I'm using (Wrox's "Professional C#") while
    pretty
    > good in many ways is a bit light on detailed ASP examples, and I couldn't
    find
    > anything about this in the ASP tutorials I looked at.
    >
    > Thanks for any help.
    >
    > Mike
    >

    MS News Guest

  5. #4

    Default Re: Very basic ASP.NET question

    Sorry missed declaring 'myStrvar'

    protected string myStrvar;

    private void Page_Load(object sender, System.EventArgs e)

    {

    myStrvar = "Hello Universe";

    Page.DataBind();

    // Put user code to initialize the page here

    }

    "MS News" <sql_agentman@hotmail.com> wrote in message
    news:%23Rj$lf5WDHA.1004@TK2MSFTNGP12.phx.gbl...
    > Mike
    >
    > In your HTML put
    >
    > <asp:Label ID="lblID" runat="server"><%# myStrvar %></asp:Label>
    >
    > In your Codebehind put in C#
    >
    > private void Page_Load(object sender, System.EventArgs e)
    >
    > {
    >
    > myStrvar = "Hello Universe";
    >
    > Page.DataBind(); // you need this
    >
    > // Put user code to initialize the page here
    >
    > }
    >
    > "Mike Christie" <mikec@athensgroup.com> wrote in message
    > news:VQidneobwe-nhq2iRTvUpQ@giganews.com...
    > > I've got some Java experience but no JSP or ASP and am trying to get to
    > grips
    > > with ASP.NET. I'd appreciate some help on a simple question.
    > >
    > > I have been able to get databinding to work, and can display a string
    > obtained
    > > from the database on the screen by binding it to a label. However, if I
    > have
    > > an object instantiated in the page's scope, it seems like there should
    be
    > an
    > > easier way to output a string that I obtain from that object. I gather
    > that
    > > in JSP there was some syntax like:
    > >
    > > <%= myObject.aStringProperty %>
    > >
    > > that would substitute the value of this as a literal in the middle of
    the
    > > html. I tried this syntax in ASP.NET with no luck; is there something
    > > analogous? The reference I'm using (Wrox's "Professional C#") while
    > pretty
    > > good in many ways is a bit light on detailed ASP examples, and I
    couldn't
    > find
    > > anything about this in the ASP tutorials I looked at.
    > >
    > > Thanks for any help.
    > >
    > > Mike
    > >
    >
    >

    MS News Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139