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 ?

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

It worked, i then accessed the properties like this in the ascx file : <%= Placeholder %>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.