I have this static method here:
public static string ParseStringForSpecialChars(string stringToParse)
{
const string regexItem = "[^a-zA-Z0-9 ]";
string stringToReturn = Regex.Replace(stringToParse, regexItem, @"\$%&'");
return stringToReturn;
}
This method works fine as it stops many strings from being harmful to my application. I suppose there's a better way to do things, but that's not the point of my post.
Right now what I want is to get all values from any textboxes in a javascript that would call this method and then send the data to the controller.
Say that I have this view:
@using MyApp.Utilities
@model List<MyApp.Models.CustomerObj>
@{
ViewBag.Title = "Customer Index";
}
<h2>Customer Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
@using (Html.BeginForm())
{
<p>
Name: @Html.TextBox("customerName") <br/>
Address: @Html.TextBox("customerAddress") City: @Html.TextBox("customerCity") <br/>
<br />
Postal Code: @Html.TextBox("customerPC")<br/>
Phone Number: @Html.TextBox("customerPhone") Fax Number: @Html.TextBox("customerFax")<br />
Mail: @Html.TextBox("customerEmail") <br/>
<input type="submit" value="Filter" style="float:right">
</p>
}
</p>
How could I proceed to do what I want to do? Can anyone offers me suggestion how to proceed? I would like a flexible workaround since the view you have right now will change and I would need this method to be appliable everywhere.
Thank you.