There is no preparation for the opening... Let me talk about my development model first.

Source: Internet
Author: User

 

It wasn't long before I went out ,... So what's wrong or bad? I hope you can give me some advice... I also want to learn ..

 

I use mvc4 and ef6 .. So I generate models directly...

 

I will use a background verification to explain my development model...

Verify that the currently registered user name is available ..

..

 

 

 

 

This is a simple verification.

It's easy to understand ..

Use ajax to get the value of the text box

 

 

<Input type = "text" id = "txtname" onblur = "checkuser ()"/>

Onblur is executed when the text box loses focus

 

Function checkuser (){
VaR username = $ ("# txtname"). Val ();
$. Ajax ({
Type: "Post ",
Async: True,
URL: '@ URL. Content ("~ /Userview/GetUserName ")',
Data: {Username: username },
Success: function (data ){
If (Data! = 0 ){
Alert ("this user already exists ");
$ ("# Txtname"). Val ("");
}
}
});
}

 

The method name that points to the Controller .. The parameter is a string generated by var.

Next, the Controller

 

[Acceptverbs (httpverbs. Post)]
Public int GetUserName (string username)
{

Int userid = usermanageservice. getuserid (username );
Return userid> 0? 1: 0;

}

The username field in the database is queried based on the value of the text box .. Check whether the field ID exists

Determine the return value... Then 0 or 1 is returned.

 

If judgment ,,,

This is also a simple verification

 

In addition, the actionresult In the controller is of the bool type and then returns true or false for foreground verification,

 

I hope to help point out the unqualified items.

 

There is no preparation for the opening... Let me talk about my development model first.

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.