Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

jQuery not calling form .submit() when using Ajax on IE -


i using jquery plugin magic during .submit of form (creates hidden string , writes <input type="hidden"> item). on ie works if submit form via post, if use ajax, .submit callback never called. here example of flow:

<script type="text/javascript">     (function (jquery) {         jquery.fn.createhidden = function () {             // 1. want have called             $(this).submit(function () {                 var hiddentext = $(document.createelement('input'));                 hiddentext.attr('name', 'hidden');                 hiddentext.attr('type', 'hidden');                 hiddentext.val('1');                 $(this).append(hiddentext);                 alert("1");             });             // 2. came workaround             $(this).parents('div.formwrapper').submit(function () {                 var form = this.children('form');                 if (form && form.tagname == "form") {                     var hiddentext = $(document.createelement('input'));                     hiddentext.attr('name', 'hidden');                     hiddentext.attr('type', 'hidden');                     hiddentext.val('2');                     $(form).append(hiddentext);                     alert("2");                 }             });         };     })(jquery); </script>  <script type="text/javascript">     $(document).ready(function () {         $(".form").createhidden();     }); </script>  <div class="formwrapper"> @*using (html.beginform("about", "home", formmethod.post, new { @class = "form", @id = "form" }))*@ @using (ajax.beginform("about", "home", new ajaxoptions { updatetargetid = "myreply", httpmethod = "post" }, new { @class = "form", @id = "form" })) {     <div class="exposeddata">         @html.textbox("data", "", new { @class = "data" })         <input type="submit" value="button" />         <span id="myreply"></span>     </div> } </div>   
// mvc homecontroller.cs public class homecontroller : controller {     public actionresult index()     {         return view();     }      public string about(string hidden)     {         return hidden;     } } 

when using http post on ie, see alerts 1 & 2, when using ajax see alert 2. firefox shows 1. chrome, safari , opera show 1 & 2.

is there better way of fixing works on browsers? related jquery.unobtrusive-ajax.js i'm using in mvc3?

i've tried $('form').ajaxstart(), ajaxoptions{onbegin=...}, <form onsubmit=...> didn't trick called after controller visited, , hence hiddentext not included in form.

you should try jquery froms plugin - works in browsers.

and maybe rid of idea form has submit, ajax requires no forms.

hidden inputs inside forms not recommend, can manipulated.

edit:

including plug-in plug-in not best way...

i'd rather recommend use native $.ajax function, here's real-world example wrote:

$('li.sheet').unbind().bind('click', function() {     $.id = $(this).attr('id');     if($(this).next('div.edit').length == 0){         $.ajax({                 url: 'ajax_handler.php?mode=form&sheet='+$.id,                 success:function(r){                     $('li#'+$.id).after(r);                     $('li#'+$.id).next('div.edit').toggle(200);                 }         });     }     else {         $(this).next('div.edit').toggle(200, function(){             $(this).remove();         });     } }); 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -