Block codes

  • Thread starter Thread starter Rodrigo m. Ferreira
  • Start date Start date
R

Rodrigo m. Ferreira

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!
 
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
 
You don't assign values to controls like this. Do it from your code behind:

LinkButton1.Text = Titulo();
 
Back
Top