This example shows typical HTML for creating a form. It uses elements for the text boxes and for the submit button. The captions for the text boxes are created by using standard elements. The and elements put a nice box around the form.
Notice that in this page, the element uses post as the value for the method attribute. In the previous tutorial, you created a form that used the get method. That was correct, because although the form submitted values to the server, the request did not make any changes. All it did was fetch data in different ways. However, in this page you will make changes—you're going to add new database records. Therefore, this form should use the post method. (For more about the difference between GET and POST operations, see the GET, POST, and HTTP Verb Safety sidebar in the previous tutorial.)
Note that each text box has a name element (title, genre, year). As you saw in the previous tutorial, these names are important because you must have those names so you can get the user's input later. You can use any names. It's helpful to use meaningful names that help you remember what data you're working with.
The value attribute of each element contains a bit of Razor code (for example, Request.Form["title"]). You learned a version of this trick in the previous tutorial to preserve the value entered into the text box (if any) after the form has been submitted.
ตัวอย่างนี้แสดง HTML ทั่วไปสำหรับการสร้างรูปแบบ จะใช้ elements for the text boxes and for the submit button. The captions for the text boxes are created by using standard elements. The and elements put a nice box around the form.
Notice that in this page, the element uses post as the value for the method attribute. In the previous tutorial, you created a form that used the get method. That was correct, because although the form submitted values to the server, the request did not make any changes. All it did was fetch data in different ways. However, in this page you will make changes—you're going to add new database records. Therefore, this form should use the post method. (For more about the difference between GET and POST operations, see the GET, POST, and HTTP Verb Safety sidebar in the previous tutorial.)
Note that each text box has a name element (title, genre, year). As you saw in the previous tutorial, these names are important because you must have those names so you can get the user's input later. You can use any names. It's helpful to use meaningful names that help you remember what data you're working with.
The value attribute of each element contains a bit of Razor code (for example, Request.Form["title"]). You learned a version of this trick in the previous tutorial to preserve the value entered into the text box (if any) after the form has been submitted.
การแปล กรุณารอสักครู่..
