I need to create a helper function for UpdatePanelAnimation extender from AjaxControlToolkit in asp.net mvc. I downloaded the toolkit and loaded the js files into my project.
Can someone please tell me how should I write this helper function and what all parameters are to be passed into it.
I am new to asp.net and mvc
thanks for the reply. but we have to include more helper functions in mvc in the near future. so i need to implement this anyway.
Since you have jQuery, using UpdatePanel and UpdatePanelAnimation is not desired in ASP.NET MVC. You can use jQuery Animate method:
http://jqueryui.com/demos/animate/#source
First you call animate to hide panel, then you use post or get ajax method and in callback you call animate to come back to previous state. If you do it properly, it will look like UpdatePanelAnimation and have very nice looking code.
Related
I am new to ASP.NET MVC .
To start learning on MVC, I was going through a tutorial on MVC, where they used the Page_Load event which is same as in Web forms.
Does MVC support events, and if so what events are supported?
If ASP.NET MVC does not support Page_Load event, then what is the alternative?
One thing that i was told before learning MVC was, 'Just forget everything about Webforms. It's old, and doesn't support separation actually.' Don't think about asp.Net webforms while learning MVC. MVC has a different life cycle.
An answer to your question is, MVC doesn't support Page_Load or any event, and it all depends on what you want to implement. Here are few tips:
1.) If you want to implement something before View (UI or html page) is rendered, you can write logic in controller before returning the View.
2.) If you want to implement something in the process of rendering page, you can use razor markups. It is quite easy to use razor.
3.) If you want to implement something after Page has been totally rendered, you can use jQuery's document.Ready().
You can start learning MVC here: http://asp.net/mvc
You should use Javascript/Jquery for event handling in MVC application. You may be use document.Ready() event handler to trigger the page load event and then handle your logic using javascript/jquery.
I am very new to MVC and Presently I need to work on a Project in MVC4 with Razor engine.
So can any one tell me about
How to implement logic for SelectedIndex Change event of dropdwonlist in MVC4?
Thanks.
In MVC you can't do this. You'd need to use jQuery. OnSelectedIndexChange is a concept that is used in ASP.Net, and MVC3 is vastly different. If you want to implement logic when a user changes a DDL, you'd need a jQuery function to run when the DDL changes (onchange html attribute), which would then pass a request with AJAX to a controller on your page. Within this controller you'd be able to implement this logic.
I'd recommend getting familar with the concepts of MVC first. Practises in ASP.Net are rarely interchangeable with MVC.
I need to port the functionality of this one and only one AJAX control to MVC, but given the poor selection of MVC controls out there, I think I need to bring this legacy control into the MVC world...
I'd rather not taint my MVC project with ASP.NET controls, and welcome json/MVC alternatives you know of. (post them if you know of any)
Sample UI that I need in ASP.NET MVC
Back to porting
Although it's unfortunate that I am left to porting this control to MVC, it seems to be a widely accepted practice since Telerik has detailed instructions on how do this.
That makes me ask:
How common is it for a MVC website to use ASP.NET controls?
Again I'll mention I don't want to do this so I welcome MVC-specific alternatives. That being said, I'll proceed with trying to merge that control with my existing site. </End Disclaimer>
If you click on this hyperlink, and look at the source code at the bottom, can you tell me where I should put the following in MVC?
Code behind (My first instinct is to use a Controller but another SO question indicates I should create a create a ViewName.aspx.cs file)
How do I port the SQLDataSource to the new "Model" way of thinking. I know they are different in nature but I don't know how to present data to a ASP.NET control in a way that it will consume the information.
How do I handle the AJAX component? This control has an AJAX component using callbacks. Yes this is getting ugly, but it seems like I have to do this.
Apparently this model saves data in session or view-state. I have no idea if this even work in MVC. Guidance, an alternate control, or a life preserver is much appreciated.
I've already done research and have instructions from Telerik here and here that describes how to get started with placing a simple menu, but I need a little assistance with the more complex controls like this one.
Note: For all the commentary that has hit this question, please remember that I only want this one ASP.NET control functionality; I can't find a comparable control in MVC.
porting from asp.net webforms to MVC is a paradigm shift.
Directly porting does not work.
The Model is where you typically describe your data and do the data access
the View is for displaying the data
The controller plums the other two together
So SQLDataSource is your data access layer and would therefore go to your model
the problem with the thought pattern of SQLDataSource == Model then you get away from the point of decoupling your presentation from data access
You have to think of MVC development as a new build
I would pick a book or video series from your preferred source and learn starting with MVC3 (it has some differences that simplify build speed and reinforce the difference between webforms and mvc)
Hope this helps.
This article explains how to run web forms and mvc together
http://weblogs.asp.net/rajbk/archive/2010/05/11/running-asp-net-webforms-and-asp-net-mvc-side-by-side.aspx
This is by telerik and explains the limitiation of the grid and what is need to get it to run.
http://blogs.telerik.com/aspnetmvcteam/posts/08-11-06/asp_net_ajax_controls_in_asp_net_mvc.aspx
Add an IFrame in your MVC view that just shows the WebForms page (or just use that control on a single WebForms page).
There is nothing that says you can't have a site with both WebForms and MVC pages. You can route a single URL to a WebForm just for this control.
Why not just use the telerik MVC controls? They work quite well. Either get them via a NuGet package or visit this link http://www.telerik.com/products/aspnet-mvc.aspx
I would rather use ViewModel instead of code behind
You don't have to throw away SqlDataSource you can use result set and buld from it your model, problem may be column names in result set... tricky but can be done
Since there is no components in MVC except helpers youll need help of jQuery probably, it easy
$.ajax({
url : "/controller/action",
data: { /*json or serialized form */ },
successs: function(data){
//if you got response as html from /controller/action
$("#some_div").html(data);
}
}
Session is available in MVC but viewstate not, you can use HttpContenxt.Cache or TempData if you need something like viewstate. USe TempData to keep data between redirections, or httpcontext.cache to cache your data further more.
I can't find similar functionality in an MVC control
MVC doesn't really have a concept of controls in the same way that ASP.Net does - there are only really the plain old HTML controls (i.e. hidden input, text input, checkbox, radiobuttons, select box, text area, password and buttons).
When you need something more complicated than the plain HTML Controls you need to use some JavaScript to achieve this.
I'm not sure that you will be able to 'port' the control into MVC - you will most likely have to try and re-create it your self using an MVC controller and a partial view with a fair bit of a javascript to create the control.
Have a look at the JQuery UI Autosomplete plugin - you could probably use this to acheive something similar
How suitable is ASP.NET MVC for developing anything like
http://www.google.com/ig?
I haven't seen or failed to find any examples yet. Does the MVC approach imply that the user interface is not supposed to look like that?
Check out http://aspspider.info/lakkakula/local.aspx, it is Web 2.0 Portal developed using Asp.Net MVC 1.0, Microsoft Ajax Client Templates and jQuery with drag and drop widget personalization much like google.com/ig.
MVC is quite suitable for such a UI. Your main controller can render with a list of the widgets the user has defined, or an ajax call to a method returning a JsonResult can be used... this can generate the wrappers client-side calling for each partial vie for the corresponding controls. I would think that MVC would simplify things quite a bit.
MVC + jQueryUI would be about all you'd need...
I guess a little bit more clarification, what exactly do you mean by "suitable"?
One method might be for each available "widgit" to be a controller, and then you can use jQuery (or whatever you want) to call the specified method and render. The page would then have a series of "lists" (which you can store in the DB) against the user and you can simply order those lists to display the relevant widgits in the correct order.
Obviously, that's a VERY large simplification....
See the tutorial Developing Web 2.0 Portal using ASP.NET MVC, Microsoft Ajax Client Templates and jQuery with drag and drop widget personalization.
I am trying to create an upload control for ASP.NET MVC with jQuery progress bar. In ASP.NET the implementation works no problems, but in MVC the problem is that the server doesn't respond to my callbacks until the file is uploaded.
The upload control is based on html file upload element, and I cannot for the life of me, understand how MVC handles postback + callback synchronously ?
I have searched for a whole bunch of answers, but all I can find is a "callback+callback" solution and NOT a postback+callback.
Does anyone have any idea how to solve this problem for MVC ?
Thanks
Hrmmm,
Thomas, MVC does not handle post-backs at all. Because a URL is directly routed to an Action method on a controller, a form is not meant to actually post-back to itself. Further more, all of the post back processing that Asp.Net had to handle post-backs on the server was pulled out of the .Net MVC framework.
A better approach to accomplish what you're trying to do with a progress bar would be to use JQuery with AJAX to make the call to your server and then use Javascript/CSS (possibly a lightbox approach) or a pop-up window to inform the user that they are waiting. When the Ajax call completes it's work, you can have Javascript fire the redirect to the page in your MVC that you want the user to be redirected to after the action has been performed. Making AJAX calls with JQuery is a total breeze and is pretty fun to play around with as well!
Check it...
Suggestion:
You can use the JQuery Uploadify control to show the status of
the upload. This control has a flash and html 5 type controls. Use whichever is applicable to you.