Step by step use ext js mvc and ASP. Net MVC 3 to develop a simple CMS background management system and adjust the homepage display

Source: Internet
Author: User

After logging on to the system, you must adjust the homepage display so that the system interface is displayed after you log on.

Determine the isauthenticated method of the request before and after logon. Because different scripts need to be executed through the server segment code, the Loder public code should be extracted independently in a script block, and different scripts should be in different codes, the final code is as follows:

<SCRIPT>

Ext. loader. setconfig ({

Enabled: True,

Paths :{

'Ext. UX ': 'scripts/extjs/UX'

}

});

</SCRIPT>

 

@{

If (request. isauthenticated)

{

<SCRIPT>

</SCRIPT>

}

Else

{

<SCRIPT>

Ext. Require ('ext. UX. login ');

 

Ext. onready (function (){

If (ext. blank_image_url.substr (0, 4 )! = "Data "){

Ext. blank_image_url = "content/images/s.gif ";

}

 

Ext. UX. login. Show ();

})

</SCRIPT>

}

}

 

 

 

Because you need to call the application to generate the interface, you need to let ext JS know the application directory, so Add the following code to the paths of Loader:

'Simplecm': 'scripts/app'

 

After Authentication, you need to write user information such as an object to control the permissions of the application. Therefore, add the following code:

VaR roles = roles. getrolesforuser (user. Identity. Name );

VaR rolesstring = "";

Foreach (var c in roles)

{

Rolesstring + = string. Format ("'{0}',", C );

}

Rolesstring = rolesstring. substring (0, rolesstring. Length-1 );

<SCRIPT>

 

Simplecms. userinfo = {

Roles :[

@ Html. Raw (rolesstring)

]

};

 

</SCRIPT>

 

Here, the user role is simply written into the userinfo object. If you need other user information, you can construct the object based on the actual situation, as long as it is easy to access.

There is a problem here, that is, all objects simplecms may be null here, so you need to call the NS method of ext to name it. This can be added to the loader and the code is as follows:

Ext. NS ('simplecm ');

 

Now, open the home page in the browser and log on with Admin. In firebug, the source code shown in 16 is displayed, indicating that you have already logged on separately before and after logon.

Figure 16 page source code displayed in firebug

The homepage has been adjusted. The next step is to write what ext js mvc requires.

Code: http://download.csdn.net/detail/tianxiaode/4572323

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.