دسترسی به یک متغیر از code in line در codebehind

Rate this post

how to call a variable in code behind to aspx page

The field must be declared public for proper visibility from the ASPX markup. In any case, you could declare a property:


private string clients;
public string Clients { get { return clients; } }

UPDATE: It can also be declared as protected, as stated in the comments below.

Then, to call it on the ASPX side:

<%=Clients%>

Note that this won’t work if you place it on a server tag attribute. For example:

<asp:Label runat=”server” Text=”<%=Clients%>” />

This isn’t valid. This is:

<div><%=Clients%></div>

بیشتر بخوانید:   چه زمان‌هايي يك برنامه‌ي ASP.NET ري استارت مي‌شود؟

Check Also

لیست id والدهای یک نود و pid در سیستم سلسله مراتبی

لیست id والدهای یک نود و pid در سیستم سلسله مراتبی

همیشه از این حالت سلسله مراتبی یا Hierarchical ,  recursive خوشم میومد یه مثال خیلی ساده …

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *