开发者

Access UserControl Property From ascx file

开发者 https://www.devze.com 2023-02-15 12:13 出处:网络
I have a function that Localize the text of my control. // code behind lblName.Text = Localiza开发者_开发问答tion.GetLocalValue( \"Updated\" , this.Path );

I have a function that Localize the text of my control.

// code behind
lblName.Text = Localiza开发者_开发问答tion.GetLocalValue( "Updated" , this.Path );

and I know that i can call a function inside ascx file.

// ascx file
Text='<%#Global.Convert( (DateTime)(Eval("CreatedDate")) %>'

How can i Get Path Property in ascx file To call GetLocalValue ?


You just need to create public property Path in code behind:

public string LocalizedPath
{
  get
    {
      return Localization.GetLocalValue( "Updated" , this.Path);
    }
}

And than you can use it in .aspx:

<script type="text/javascript">
  alert('<%= LocalizedPath %>');
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消