0

I would like to create a masked textbox (user control) using a jquery plugin but I want to send parameters from my aspx page to my ascx file in order to call a javascript function which has parameters like the mask, the placeholder, etc ...

This is my line of code in my aspx page :

<UC:MaskedTextBox runat="server" ID="MaskedTextBox1" Mask="9999" Placeholder="_" Text="1234" />

This is what I have in my asxs file :

<script type="text/javascript">
    $(document).ready(function () {CreateMaskedTextBox('" + _Id + "', '" + _Mask + "', '" + _Placeholder + "', '" + _Text + "');});
</script>
<asp:TextBox ID="MaskedTextBox_TextBox" runat="server"></asp:TextBox>

How can i get the id, mask, placeholder that I have initialized in the aspx page ?

Stan
  • 391
  • 2
  • 5
  • 21

1 Answers1

1

Declare properties in the code behind like this:

public string PlaceHolder { get; set; }

Do it for each parameter you need. You can check this question too: Pass data from a ASP.NET page to ASCX user controls loaded dynamically

Community
  • 1
  • 1
ADreNaLiNe-DJ
  • 4,787
  • 3
  • 26
  • 35
  • It worked, i then accessed the properties like this in the ascx file : <%= Placeholder %> – Stan Jan 28 '16 at 14:05