Block codes

Discussion in 'ASP .Net' started by Rodrigo m. Ferreira, Sep 10, 2008.

  1. Whats wrong with this code?

    on the default.aspx I have this:

    <asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click"
    Text='<%=Titulo(); %>'></asp:LinkButton>

    on the default.aspx.cs I have this:

    private string Titulo()
    {
    return "Rodrigo";
    }

    In this case the function is not usefull, but i am just making some tests.
    The problem is that the text of the LinkButton1 is blank.

    Sorry about my bad english.

    Thanks for helping!
     
    Rodrigo m. Ferreira, Sep 10, 2008
    #1
    1. Advertising

  2. Rodrigo m. Ferreira

    Med Guest

    Try protected or public instead of private

    protected string Titulo()
    {
    return "Rodrigo";
    }

    Or bettter way of assigning a value to you LinkButton text is:
    LinkButton1.Text = "Rodrigo"; in your code behind.

    Med

    "Rodrigo m. Ferreira" <> wrote in message
    news:...
    > Whats wrong with this code?
    >
    > on the default.aspx I have this:
    >
    > <asp:LinkButton ID="LinkButton1" runat="server"
    > onclick="LinkButton1_Click" Text='<%=Titulo(); %>'></asp:LinkButton>
    >
    > on the default.aspx.cs I have this:
    >
    > private string Titulo()
    > {
    > return "Rodrigo";
    > }
    >
    > In this case the function is not usefull, but i am just making some tests.
    > The problem is that the text of the LinkButton1 is blank.
    >
    > Sorry about my bad english.
    >
    > Thanks for helping!
     
    Med, Sep 10, 2008
    #2
    1. Advertising

  3. Rodrigo m. Ferreira

    Scott M. Guest

    You don't assign values to controls like this. Do it from your code behind:

    LinkButton1.Text = Titulo();



    "Rodrigo m. Ferreira" <> wrote in message
    news:...
    > Whats wrong with this code?
    >
    > on the default.aspx I have this:
    >
    > <asp:LinkButton ID="LinkButton1" runat="server"
    > onclick="LinkButton1_Click" Text='<%=Titulo(); %>'></asp:LinkButton>
    >
    > on the default.aspx.cs I have this:
    >
    > private string Titulo()
    > {
    > return "Rodrigo";
    > }
    >
    > In this case the function is not usefull, but i am just making some tests.
    > The problem is that the text of the LinkButton1 is blank.
    >
    > Sorry about my bad english.
    >
    > Thanks for helping!
     
    Scott M., Sep 10, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2FsdmFkb3I=?=

    Block codes on ASP.NET

    =?Utf-8?B?U2FsdmFkb3I=?=, Jun 22, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    640
    Karl Seguin
    Jun 22, 2005
  2. Greg  --
    Replies:
    4
    Views:
    2,272
  3. morrell
    Replies:
    1
    Views:
    1,004
    roy axenov
    Oct 10, 2006
  4. Replies:
    2
    Views:
    2,982
    Malcolm
    Aug 20, 2005
  5. Allen
    Replies:
    1
    Views:
    682
    Mark Rae [MVP]
    Dec 3, 2007
Loading...

Share This Page