Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static MvcHtmlString SendMailTo(this HtmlHelper helper, string emailAddress, string subject, string displayText)
- {
- var sb = string.Format("<a href="{0}{1}{2}" title="{1}">{3}</a>",
- CharEncode("mailto:"), CharEncode(emailAddress),CharEncode("?subject=" +subject), CharEncode(displayText));
- return new MvcHtmlString(sb);
- }
- public static string CharEncode(string value)
- {
- var enc = System.Text.Encoding.Default;
- var retval = "";
- for (var i = 0; i < value.Length; i++)
- {
- retval += "&#" + enc.GetBytes(new[] { Convert.ToChar(value.Substring(i, 1)) })[0] + ";";
- }
- return retval;
- }
- <div class="form-group">
- @Html.LabelFor(m => m.ApplicationId, new { @class = "col-sm-3 control-label" })
- <div class="col-sm-8">
- @Html.TextBoxFor(m => m.ApplicationId, new {@class = "form-control"})
- </div>
- </div>
- <div class="form-group">
- <div class="col-sm-11" style="text-align:right">
- @Html.SendMailTo("info@test.com", "Password Request: ", "Request Password")
- <button type="submit" class="button">Sign in</button>
- </div>
- </div>
- `$('.class of your textbox').val()' //will return a string
- c.1 Place your partial view in a `div element`
- c.2 Make an `ajax` call from `jquery` to an action which returns your partial view filled with data
- Example for c.2:
- *AJAX*
- $.ajax({
- type:"GET",
- data:{
- mail:$('.class of your textbox').val()
- },
- success: function(response){
- $(".class of your div").html(response.Html);
- }
- error: function(response){
- // whatever you want to do
- }
- });
- *Controller Action*
- public JsonResult(string mail)
- {
- var model = new CustomModel(){ Mail=mail }; // custom class to your as model for your partial view
- var html = RenderPartial(...) // method you can find in the link posted below
- return Json(
- {
- Html=html
- },JsonRequestBehavior.AllowGet)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement