Single URL for all the navigations in asp.net mvc3 - asp.net-mvc-3

I have a requirement of having the same URL throughout the application navigations. Like below
http://www.[Site Name]:com. (Here User should not have the idea of chaning the URL from one page to another page)
I am using ASP.NET MVC3 with latest Razor View Engine,
Can some body give suggestions on this?
Advanced Thanks,
Satish Kotha

This may make it very difficult for users to access your site - they won't be able to bookmark a specific page, for example.
It sounds like you want a single-page-app (e.g. like Google Mail or Reader). In this case, you have one page and make heavy use of AJAX. You can query the server via javascript, and send back Partial Views, or raw data in JSON format which can be rendered on the client, possibly via some kind of templating engine.

As Graham Clark has already mentioned, this functionality will most likely be frustrating for the user; however, achieving it depends on the complexity of your project. You may want to look into using jquery to load partial views into the main content area of your site.
When you click on your navigation you can use jquery's load() to replace the main content on the page. Jquery-load-with-mvc-2-partialviews is an interesting blog post that may give you more insight into what you would want to do. Your code to load content could look something like this:
$("#mainContent").load("/Controller/Action",
{parameter}, function () {
// perform javascript actions on load complete
});

Related

How to make userprofile viewing-editing in django similar to the facebook way?

I'm making a site in django which has profiles for users and companies with text fields, photos, choices, etc., and I want them to look the same while viewing or editing them (in case of the owner of the profile). Basically the user must click somewhere and all the information becomes editable, without having to go into other "profile editing" page.
The only way of doing this that I can think of is by making to different pages, one for only "viewing" the data, and other for editing it, and try to make them look the same anyhow..
I wonder, if there is an elegant and simple way of integrating this two functionalities in django?
Thanks.
You're talking about manipulating the DOM without page loads. You're going to use AJAX to retrieve your form. I would recommend using Tastypie to create REST endpoints. Then you'll need to do AJAX calls to get your form. I would recommend using jQuery.
If you would prefer something simplier. You could always user a hidden form field and then manipulate the DOM with jQuery.

Display results dynamically based on GeoLocation MVC

I am building a webpage that needs to Query the database and display events in your area based on the users GeoLocation. I've seen this done so many times now on a lot of websites. But I have never built this functionality before.
I have the GeoLocation part functioning. When you land on the page it displays your zip code. I'm not sure how to grab that Zipcode from the div and query the database immediatley.? This webpage being is built using Orchard MVC/NHibernate.
Any suggestion would be helpful.
It sounds like you want the entire solution, but I'm not going to go into that kind of detail.
So I'll give you tips:
Use jQuery to grab the zip code from the DOM
Use jQuery to do an AJAX call to a action method in one of your controllers, passing the zip
Have the controller call the DB and hydrate the results into JSON
Have the controller return a JsonResult
Have jQuery handle the response of the AJAX call and do something meaningful

Using asp.net mvc 3 + Razor with Ajax and jquery

I'm trying to make the "Google Instant" like experience (I'm not looking for Auto-complete).
Google instant is the dynamically change the "search result" as you type (not the suggestions, which can be achieved with auto complete).
The page will simply have a text input control, in which as your type, you get result below the text input control.
I know, I must make some async calls on "onKeyPress": So first how can I do that in jquery?
Second, any good tutorials on combining asp.net MVC with Razor and Ajax?
edited: as people were confusing auto-complete with instant result
The term that you should use is 'autocomplete'
Have a look at the link below:
http://docs.jquery.com/Plugins/autocomplete
It's server independant. Basically, on the server side, you must create a service, given a string return the possible values that relate to that string.
Hope this helps.
There is a great article here on how to create an instant search with Jquery, PHP and HTML
http://woorkup.com/2010/09/13/how-to-create-your-own-instant-search/
The one caveat I encountered was that you need to put the Javscript code inside a
$(document).ready(function(){
/*Your JS Instant Search goes here */
});
which wasn't clear from the article.
For ASP.NET MVC 3, create a controller/action that returns a JSON or JSONP object. If you're a beginner, this might trip you up as you will get CrossSiteJson errors. This link will help:
Ajax json post to Controller across domains, "not allowed by" Access-Control-Allow-Headers
From doing these two, I was able to do the instant search in MVC3 and it works really well.
Using Firebug or WebKit Web Inspector and Fiddler really helps.
It is still a variant of autocomplete, if you break it down:
Fire autocomplete on key presses.
Fire Ajax search on autocomplete success/load (whatever the event might be).
Writing number 2 is minimal work for you unless somebody has written a plugin that does both. It's a nice little project - write a plugin that combines a text box and div and does autosearch.

Ajax generated content, crawling and black listing

My website uses ajax.
I've got a user list page which list users in an ajax table (with paging and more information stuff...).
The url of this page is :
/user-list
User list is created by ajax. When the user click on one user, he is redirected to a page which url is : /member/memberName
So we can see here that ajax is used to generate content and not to manage navigation (with the # character).
I want to detect bot to index all pages.
So, in ajax I want to display an ajax table with paging and cool ajax effetcs (more info...) and when I detect a bot I want to display all users (without paging) with a link to the member page like this :
JohnBob...
Do you think I can be black listed with this technique ? If you think so, could you please provide an alternative solution by keeping these clean urls and without redeveloping the user-list (without ajax) ?
Google support a specification to make AJAX crawlable:
http://code.google.com/web/ajaxcrawling/docs/specification.html
I did an experiment and it works:
http://seo-website-designer.com/SEO-Ajax-Google-Solution
As this is a Google specification, you won't get penalised (unless you abuse it).
Saying that, only Google support it at the moment (AFAIK).
Also, I believe following the concept of Progressive Enhancement is a better approach. That is, create a working html website then make the JavaScript enhance it
Maybe use the urls with an onclick to trigger your AJAX scripting? Like
Some URL
I don't think Google would punish you for this, you primarily use JScript, but you do provide a fall back for their bot, so your site doesn't get any less accessible.
EDIT
Ok, I misunderstood. Then my guess would be you basically have two options:
1. Write a different part of your site where bots end up, or,
2. Rewrite your current site to for example always give a 'full' page, with an option to only get, say, the content div. Then you can get only the content with JavaScript, but bots will always get a nice page.

External HTML page, inside AJAX Iframe?

Hi Masters Of Web Development.
I have a not that simple question this time. I have got a simple external HTML page, that I want to include in my site. The HTML page contains a submit form or something like that, and I wish to send this data from the form, without to reload the whole page. So I decided to put HTML page inside iframe. But, some people said that this is older technology, google doesn't like iframes, etc. So I want to use something like AJAX or JQuery to load that external HTML page, and to send submit form without reloading the whole page with it. :)
Any suggestions on how to make this?
Thanks in advance :)
Do you really need Google to index that iframe form? If that's the only iframe you have throughout the site, it aint going to be a problem in terms of google indexing.
About using the Iframe, if you are not comfortable learning and building ajax-type form, you'll still be fine (like what Frankie commented). Just make sure the form works, usable and compatible with popular browsers.
You want to use the jQuery Forms Plugin. Its very straightforward and easy to turn any normal HTML form into an AJAX form.

Resources