Skalis
Skalis

Reputation: 197

Dynamic html output using <% %>

I have a page which can be in English or Swedish. The page contains a lot of phone numbers. What I want to do is show phone numbers as 0XX XXX XXX when in Swedish mode, and +46(0)XX XXX XXX when in English mode.

I'm not too keen on using unique asp.net-controls for each and every phone number as they are quite a few. What I'm thinking is using <% Phone(); %>. Problem is nothing gets outputed. The debugger does however run the Phone method. Any ideas/recommendations? Can <%%> only be used in conjunction with data controls?

Code:

<strong>Phone:</strong> <%Phone(); %>418 43 30 30<br>

public string Phone()
{
    if (Session["lang"].ToString() == "SE")
        return "0";
    return "+46(0)";
}

Upvotes: 0

Views: 238

Answers (1)

Sergey Rybalkin
Sergey Rybalkin

Reputation: 3026

Try this - <%=Phone(); %>. You need = in order for the return value to be placed within HTML code.

Upvotes: 2

Related Questions