forum

Home / DeveloperSection / Forums / How to Processing textual inputs in the client side

How to Processing textual inputs in the client side

Anonymous User 1871 15-Jan-2015

Using ASP.NET MVC 5 and Razor view engine, is there a way to get the values of input fields before posting the data to the server, processing them and then sending the processed data instead?

For example:

@using (@Html.BeginForm("ViewPage", "Home",FormMethod.Post)) {
     @Html.TextBox("Field1")
     @Html.Hidden("Field2");
     <input type="submit"id="HiddenButton" value="Submit" style="display:none" />
     <input type="button"id="VisibleButton" value="Submit" />   
}

and now :

<script type="text/javascript">
     document.ready(function() {
        $("#VisibleButton").click(function() {
             var Temp =$("#Field1").val()
             @{
                 // C# Area Processing the Temp, by for example calling an extension method and
                 assigning the new value to the Hidden Field
              }
              $("#HiddenButton").trigger("click")
        })
     })
</script>

I'd like to do this , because I wanna encrypt a text before sending it to the server and I've already made my encryption method in C#.


Updated on 15-Jan-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By