Click here to Skip to main content
15,746,652 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
So, I have a User Control for a textbox and I have added a RegularExpressionAttribute Property to it. Below is the property I created:

What I have tried:

<pre>Dim _regex As New RegularExpressionAttribute("/[^0-9a-zA-Z-,_.\:\s]+/g")
    Public Property Regex() As RegularExpressionAttribute
            Return _regex
        End Get
        Set(ByVal value As RegularExpressionAttribute)
            _regex = value
        End Set
    End Property

Now, the GET is working fine, but SET doesn't work as expected.

In my aspx page, I'm trying to set the value for that property like below:

<uc1:CheckedTextBox ID="TxtScope" runat="server" Regex-Pattern="/[^0-9a-zA-Z-_.\:\s]+/g"></uc1:CheckedTextBox>

But, I'm not able to set that value to the property. Any idea how to achieve this? Any help would be greatly appreciated.
Prifti Constantine 2-Jan-19 8:17am    
Dont you have a text tag inside the checkedTextBox control that might help?
Member 13952925 2-Jan-19 10:34am    
Yes @PriftiConstance. I do have a text tag. But, yeah I figured it out. Thanks for your response though. For some reason, it was'nt working when I use Regex-Pattern="/[^0-9a-zA-Z-_.\:\s]+/g" or Regex="/[^0-9a-zA-Z-_.\:\s]+/g" in the aspx page. So, I declared a RegularExpressionAttribute in the backend and called it in the apsx page using Razor. It worked.
Prifti Constantine 3-Jan-19 2:03am    
Cheers on that!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900