How do I force full post-back from a button within an UpdatePanel?

You can use the Triggers property of the UpdatePanel to register actions that trigger a full postback. Add a PostBackTrigger object to that property, containig the ControlID of the control which needs to trigger a full postback. <asp:UpdatePanel ID=”UpdatePanel1″ UpdateMode=”Conditional” runat=”server”> <ContentTemplate> … </ContentTemplate> <Triggers> <asp:PostBackTrigger ControlID=”myFullPostBackControlID” /> </Triggers> </asp:UpdatePanel>

Rebinding events in jQuery after Ajax update (updatepanel)

Since you’re using ASP.NET AJAX, you’ll have access to a pageLoad event handler, that gets called each time the page posts back, be it full or partial from an UpdatePanel. You just need to put the function in to your page, no hooking up is required. function pageLoad(sender, args) { if (args.get_isPartialLoad()) { //Specific code … Read more

How can I convince IE to simply display application/json rather than offer to download it?

I found the answer. You can configure IE8 to display application/json in the browser window by updating the registry. There’s no need for an external tool. I haven’t tested this broadly, but it works with IE8 on Vista. To use this, remember, all the usual caveats about updating the registry apply. Stop IE. Then, cut … Read more

Setting Access-Control-Allow-Origin in ASP.Net MVC – simplest possible method

For plain ASP.NET MVC Controllers Create a new attribute public class AllowCrossSiteJsonAttribute : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { filterContext.RequestContext.HttpContext.Response.AddHeader(“Access-Control-Allow-Origin”, “*”); base.OnActionExecuting(filterContext); } } Tag your action: [AllowCrossSiteJson] public ActionResult YourMethod() { return Json(“Works better?”); } For ASP.NET Web API using System; using System.Web.Http.Filters; public class AllowCrossSiteJsonAttribute : ActionFilterAttribute { public override void … Read more

ASP.NET MVC controller actions that return JSON or partial html

In your action method, return Json(object) to return JSON to your page. public ActionResult SomeActionMethod() { return Json(new {foo=”bar”, baz=”Blech”}); } Then just call the action method using Ajax. You could use one of the helper methods from the ViewPage such as <%= Ajax.ActionLink(“SomeActionMethod”, new AjaxOptions {OnSuccess=”somemethod”}) %> SomeMethod would be a javascript method that … Read more

jQuery $(document).ready and UpdatePanels?

An UpdatePanel completely replaces the contents of the update panel on an update. This means that those events you subscribed to are no longer subscribed because there are new elements in that update panel. What I’ve done to work around this is re-subscribe to the events I need after every update. I use $(document).ready() for … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)