The MVC bits have finally arrived and I’ve spent a while digesting them. I’ve been waiting for the bits to be released to begin working on a side-project, so the first thing I did after downloading them last night was crank it up and start working on a new ASP.NET MVC Web Application project.
Typically, the first thing I do on a new project is set up the authentication/authorization system. For the project I am working on I want to use the ASP.Net Membership system, but most of the Membership controls do not work with the MVC framework because they require postbacks. I spent some time last night building a Security controller and views for Registration and Login that I thought would be worth sharing.
So far I have implemented basic functionality for Register, Login, and Logout. There are three files we will have to create. We will also have to change the routing table. Let’s start with the SecurityController:
1 public class SecurityCont ......
1. ´ò¿ªÐµĴ°¿Ú²¢´«ËͲÎÊý£º
¡¡¡¡´«ËͲÎÊý£º
response.write("£¼script£¾window.open(’*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)£¼/script£¾")
¡¡¡¡½ÓÊÕ²ÎÊý£º
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
¡¡¡¡2.Ϊ°´Å¥Ìí¼Ó¶Ô»°¿ò
Button1.Attributes.Add("onclick","return confirm(’È·ÈÏ?’)");
button.attributes.add("onclick","if(confirm(’are you sure...?’)){return true;}else{return false;}")
¡¡¡¡3.ɾ³ý±í¸ñÑ¡¶¨¼Ç¼
int intEmpID = (int)MyDataGrid.DataKeys[e.Item.ItemIndex];
string deleteCmd = "DELETE from Employee where emp_id = " + intEmpID.ToString()
¡¡¡¡4.ɾ³ý±í¸ñ¼Ç¼¾¯¸æ
private void DataGrid_ItemCreated(Object sender,DataGridItemEventArgs e)
{
¡¡switch(e.Item.ItemType)
¡¡{
¡¡¡¡case ListItemType.Item :
¡¡¡¡case ListItemType.AlternatingItem :
¡¡¡¡case ListItemType.EditItem:
¡¡¡¡¡¡TableCell myTableCell;
¡¡¡¡¡¡myTableCell = e.Item.Cells[14];
¡¡¡¡¡¡LinkButton myDeleteButton ;
¡¡¡¡¡¡myDelete ......
Ó¦ÓÃ1£ºGridViewºÍCheckBox½áºÏ
Ч¹ûͼ£º
Ó¦ÓÃ2£ºExtending the GridView Control
Code download available at: CuttingEdge05.exe (132 KB)
Browse the Code Online
Contents
The GridView Difference
A New GridView Control
Adding a Checkbox Column
The New Grid In Action
Styling Selected Rows with Script Code
Script Code Injection
Wrap-Up
.............
Ó¦ÓÃ3£ºUsing TemplateFields in the GridView Control
Ó¦ÓÃ4£ºHow to select row in gridview on click ......
ģ̬´°¿Úÿ´ÎÒ³ÃæÖØдò¿ª²»Ë¢Ð¡£
»º´æµÄÔÒò£¬¸Ä³ÉÕâÑù£º
½â¾ö°ì·¨¡£¡£¡£
url = frmWin + "? " + Math.random();
window.showModalDialog(url,me, 'dialogWidth= '+width + 'px;dialogHeight= '+height+ 'px;help:no;status:no;resizable:no;scro ll:no; ')
Èç¹ûÄãµÄfrmWinµØÖ·ÒѾÓÐ?ºÍºóÃæµÄ²ÎÊý¾Í¸Ä³É
url = frmWin + "& " + Math.random();
window.showModalDialog(url,me, 'dialogWidth= '+width + 'px;dialogHeight= '+height+ 'px;help:no;status:no;resizable:no;scro ll:no; ') ......
ASP.NET 2.0 AjaxÖÐÄܹ»ÔÚ¿Í»§¶ËjsÖкܷ½±ãµØµ÷Ó÷þÎñÆ÷Webservice£¬ÒÔÏÂΪһЩµ÷ÓõÄʾÀý¡£±ÊÕß°²×°µÄASP.NET 2.0 AJAX
°æ±¾ÎªAJAX November CTP¡£
Èý¸öʾÀý·Ö±ðΪ£º
1 ´ø²ÎÊýµÄWS·½·¨
2 ²»´ø²ÎÊýµÄWS·½·¨
3 ²ÎÊýÀàÐÍΪDataTableµÄWS·½·¨
Ò»¡¢WebMethod
×¢ÒâÒªµã£º
1 WebMethodÀàÐèÒªÌí¼ÓÃüÃû¿Õ¼ä Microsoft.Web.Script.Services£¬´Ë¿Õ¼äÐèÒªÒýÓÃMicrosoft.Web.Preview.dll
2 ÀàÉùÃ÷¼ÓÈë±êÇ© [ScriptService]
3 ÔÚAsp.net 2.0Àï¿ÉÒÔÖ±½ÓÓÃDataTable×÷Ϊ·µ»ØÀàÐÍÁË£¬µ«ÊÇÐèÒªÔÚWeb.configÎļþÌí¼ÓÐòÁл¯×ª»»Æ÷µÄÊôÐÔ¡£DataSet¡¢DataTable¡¢DataRow¾ùÓÐת»»Æ÷
< system.web.extensions>
¡¡¡¡< scripting>
¡¡¡¡< webServices>
¡¡¡¡< jsonSerialization>
¡¡¡¡< converters>
¡¡¡¡< add name="DataSetConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataSetConverter, Microsoft.Web.Preview"/>
¡¡¡¡< add name="DataRowConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataRowConverter, Microsoft.Web.Preview"/>
¡¡¡¡< ad ......
ASP.NET 2.0 AjaxÖÐÄܹ»ÔÚ¿Í»§¶ËjsÖкܷ½±ãµØµ÷Ó÷þÎñÆ÷Webservice£¬ÒÔÏÂΪһЩµ÷ÓõÄʾÀý¡£±ÊÕß°²×°µÄASP.NET 2.0 AJAX
°æ±¾ÎªAJAX November CTP¡£
Èý¸öʾÀý·Ö±ðΪ£º
1 ´ø²ÎÊýµÄWS·½·¨
2 ²»´ø²ÎÊýµÄWS·½·¨
3 ²ÎÊýÀàÐÍΪDataTableµÄWS·½·¨
Ò»¡¢WebMethod
×¢ÒâÒªµã£º
1 WebMethodÀàÐèÒªÌí¼ÓÃüÃû¿Õ¼ä Microsoft.Web.Script.Services£¬´Ë¿Õ¼äÐèÒªÒýÓÃMicrosoft.Web.Preview.dll
2 ÀàÉùÃ÷¼ÓÈë±êÇ© [ScriptService]
3 ÔÚAsp.net 2.0Àï¿ÉÒÔÖ±½ÓÓÃDataTable×÷Ϊ·µ»ØÀàÐÍÁË£¬µ«ÊÇÐèÒªÔÚWeb.configÎļþÌí¼ÓÐòÁл¯×ª»»Æ÷µÄÊôÐÔ¡£DataSet¡¢DataTable¡¢DataRow¾ùÓÐת»»Æ÷
< system.web.extensions>
¡¡¡¡< scripting>
¡¡¡¡< webServices>
¡¡¡¡< jsonSerialization>
¡¡¡¡< converters>
¡¡¡¡< add name="DataSetConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataSetConverter, Microsoft.Web.Preview"/>
¡¡¡¡< add name="DataRowConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataRowConverter, Microsoft.Web.Preview"/>
¡¡¡¡< ad ......
ÈÏʶASP.NETÅäÖÃÎļþWeb.config
¡¡Ò»¡¢ÈÏʶWeb.configÎļþ
Web.configÎļþÊÇÒ»¸öXMLÎı¾Îļþ£¬ËüÓÃÀ´´¢´æ ASP.NET Web Ó¦ÓóÌÐòµÄÅäÖÃÐÅÏ¢£¨Èç×î³£ÓõÄÉèÖÃASP.NET Web Ó¦ÓóÌÐòµÄÉí·ÝÑéÖ¤·½Ê½£©£¬Ëü¿ÉÒÔ³öÏÖÔÚÓ¦ÓóÌÐòµÄÿһ¸öĿ¼ÖС£µ±Äãͨ¹ýVB.NETн¨Ò»¸öWebÓ¦ÓóÌÐòºó£¬Ä¬ÈÏÇé¿öÏ»áÔÚ¸ùĿ¼×Ô¶¯´´½¨Ò»¸öĬÈϵÄ
Web.configÎļþ£¬°üÀ¨Ä¬ÈϵÄÅäÖÃÉèÖã¬ËùÓеÄ×ÓĿ¼¶¼¼Ì³ÐËüµÄÅäÖÃÉèÖá£Èç¹ûÄãÏëÐÞ¸Ä×ÓĿ¼µÄÅäÖÃÉèÖã¬Äã¿ÉÒÔÔÚ¸Ã×ÓĿ¼ÏÂн¨Ò»¸öWeb.configÎļþ¡£Ëü¿ÉÒÔÌṩ³ý´Ó¸¸Ä¿Â¼¼Ì³ÐµÄÅäÖÃÐÅÏ¢ÒÔÍâµÄÅäÖÃÐÅÏ¢£¬Ò²¿ÉÒÔÖØд»òÐ޸ĸ¸Ä¿Â¼Öж¨ÒåµÄÉèÖá£
ÔÚÔËÐÐʱ¶ÔWeb.configÎļþµÄÐ޸IJ»ÐèÒªÖØÆô·þÎñ¾Í¿ÉÒÔÉúЧ£¨×¢£º£¼processModel£¾ ½ÚÀýÍ⣩¡£µ±È»Web.configÎļþÊÇ¿ÉÒÔÀ©Õ¹µÄ¡£Äã¿ÉÒÔ×Ô¶¨ÒåÐÂÅäÖòÎÊý²¢±àдÅäÖýڴ¦Àí³ÌÐòÒÔ¶ÔËüÃǽøÐд¦Àí¡£
¶þ¡¢web.configÅäÖÃÎļþ£¨Ä¬ÈϵÄÅäÖÃÉèÖã©ÒÔÏÂËùÓеĴúÂ붼Ӧ¸ÃλÓÚ
£¼configuration£¾
£¼system.web£¾
¡¡¡¡ºÍ
£¼/system.web£¾
£¼/configuration£¾
Ö®¼ä£¬³öÓÚѧϰµÄÄ¿µÄÏÂÃæµÄʾÀý¶¼Ê¡ÂÔÁËÕâ¶ÎXML±ê¼Ç
1¡¢£¼authentication£¾ ½Ú
×÷ÓãºÅäÖà ASP.NET Éí·ÝÑéÖ¤Ö§³Ö£¨ÎªWindows¡¢Forms¡¢PassPort¡¢NoneË ......