MVC4 how to implement modal popup dialog box effect--the dialog box can achieve page flipping effect (2)

Source: Internet
Author: User

In fact, the above is just how to add code to the sequential method of the expression, the code inside what each function means, how to understand? We need to ponder.

We first to understand: We in the controller is only to HttpGet, httpget understanding is actually the request. Then I want to save, what to do when inserting.

The new action is added to the controller above, of course we want to add new view (new.cshtml), there will be a code in the view.

using (Ajax.beginform ("New", "Datamodule", New ajaxoptions{

Insertionmode=insertionmode.replace,

Httpmethod= "POST"

Onsuccess= "Savesuccess"

},new{@id = "Savepersonform"}

The inside tells us:

NEW: Controller method (not associated with httpget above, need to re-establish a "httppost" new to accept the model and save the data)

Datamodule: Controller name

Onsuccess: It is the method of the JQ of index, the function can change the view data of the main page in time. Looks like no refresh update immediately after saving. It's beautiful.

That's what I'm thinking. How do I press the dialog button, do not close the window, and update the data of the window, the implementation of the dialog box under the page to effect.

Then the paging function of the foreign article is also relatively full, later I can add to the pagination part of the code points to write an article. For the master of the high-level is not necessary, left to the novice beginner to see.

I'm just proposing how to achieve the effect of Ajax changes under the dialog button.

1, we add a paragraph under the dialog box page

<div id= "content555" ></The main purpose of div> is to make this part of the text change.

2, then we in the index of JS in the dialog under the save:fuction to increase the things we want to use, what is. is actually a function of the JQ: (This function needs to understand its function)

$.ajax ({
Type"POST ",
Url:"@Url. Action ("Getaddresslist", "Address")",
Data: {Personno:parpersonno, Pageno:parpageno},
CacheFalse
DataType:"JSON ",
Successfunction (data)
{
if (data. Html)
{
$("#content555"). HTML (data. Html);

Buttonizeall ();
Setlinkabilites ();

Setpagingsummary (Parpageno);
}
Else
{
Alert‘Opps! ');
}
},
Errorfunction (exp)        
             {
                      alert (error Address: ' + exp.responsetext ';
           }                
       }); //end Ajax call
Of course it's just that the dialog box can change the text and data changes, A lot of learning needs extrapolate. There is time for me to continue to improve, but to give ideas, everyone to achieve understanding is very important.

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.