Redirecting to page method using Ajax and jQuery

Nov 26 2010 4:17 AM

Hi,

 

I am creating an ASP.NET user control extracting information from an existing MVC application. I have implemented a tab control using jQuery. It contains 4 tabs.

 

I am facing one issue here. The description is as follows:

 

When I click on next tab it has to call a function in the User control. The existing code in MVC application is as follows:

 

tabViewData.Add(new TabViewData { Name = tab.Name, Url = "#" + Url.Action("Tab", "Root", new { language = language, locale = locale, tab = index }), Index = index++, LazyLoad = true });

 

In the above line of code I am adding tab information like name, URL, index…etc.

 

The MVC code is as follows

Url.Action("Tab", "Root", new { language = language, locale = locale, tab = index })

 

In the above line of code "Tab" is the function in the page that is to be redirected after the tab click; language, locale, tab Index are the parameters to that function.

This will work in MVC since MVC is based on URL.

Now I have given URL as "/Tab/index" to redirect to Tab (function with parameter as index) and sent this URL to jQuery.get() method, but it is not redirecting to the page.

 

jQuery.get(url, function(data){

                  this.$parent.trigger('tabloaded', [data, tabMap]);

                  tabMap.$tabBody.removeClass('loading');

            }.scope(this));

 

Note: The function is in User Control but not in the page. I need to redirect to the function in the User control with the URL using JQuery.

 

I tried to post back the page directly using that URL. I am able to redirect to the page but all the styles and jQuery scripts are not working after postback.

 

Please suggest me any solutions or alternatives.

 

Thanks,

Trinadh