We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Get text (not value) of MaskEdit in Controller POST method

Hello,

I need to get MaskEdit's text in my controller method.

I can get its value using 'Parameters' as you said in Get values on postback
But I'm not able to get its text, because I want the string with the masked text and not just the pure text.

This is my MaskEdit:

<ej-mask-edit asp-for="Plate" id="maskedPlate" mask-format=">AAA-AAAA" input-mode="@InputMode.Text" />

And this is my post method:

        [HttpPost]
        [ValidateAntiForgeryToken]
        public async Task<ActionResult> Create(string maskedPlate)

Can you help me?

1 Reply

KR Karthik Ravichandran Syncfusion Team May 18, 2017 01:25 PM UTC

Hi Gregory, 
 
Thanks for contacting Syncfusion support. 
 
We have checked your query. We have maintained the strippedValue (i.e with out mask) in the maskedit element and hidden input. So, in form post back it will return the value with out masks only. To achieve your requirement you can maintain the new hidden input and update the value in that with mask by using the method get_UnstrippedValue(). Please refer the below code block. 
 
<ej-mask-edit ej-for="@Model.inputmode" id="maskedPlate" mask-format=">AAA-AAAA" input-mode="@Syncfusion.JavaScript.InputMode.Text" create="oncreate" change="onchange"/> 
 
[script] 
function oncreate(args) { 
    var hidden = "<input type = 'hidden' id='custom" + this.element.attr('id') + "' name='" + this.element.attr('id') + "_hidden1' />" 
    this.wrapper.append(hidden) 
} 
 
function onchange(args) { 
    $('#custom'+ this.element.attr('id')).val(this.get_UnstrippedValue()); 
} 
 
[controller] 
 
public IActionResult Index(FormCollection collection) 
{ 
    string name = Request.Form["maskedPlate_hidden1"]; 
             
    return View(); 
} 
For your convenience, we have attached the sample below, 
 
 
Please let us know if you need further assistance in this. 
 
Regards, 
Karthik R 


Loader.
Up arrow icon