1. How to control the checkbox Selection in datalist cannot exceed 3
. CS
Private void datalistpolicitemdatabound (Object sender, system. Web. UI. webcontrols. datalistitemeventargs E)
{
Checkbox cbx = (checkbox) E. Item. findcontrol ("checkbox1 ");
Cbx. Attributes. Add ("onclick", "checkit (this )");
}
. Aspx
<Script language = JavaScript>
VaR num = 0;
Function checkit (OBJ ){
If (obj. Checked ){
Num ++;
} Else {
Num --;
}
If (Num> 3 ){
Num --;
OBJ. Checked = false;
Alert ("no more than three! ");
}
}
</SCRIPT>
2. Delete selected rows from datalist
<Itemtemplate>
<Span style = "cursor: Hand" id = "span <% # (messaging. dataprovider. messagerecord) getdataitem ()). id %> "onclick =" deletemessge (<% # (messaging. dataprovider. messagerecord) getdataitem ()). id %>, this) "> Delete </span> <a href =" reply. aspx? Originchatto = <% # (messaging. dataprovider. messagerecord) getdataitem ()). chatto %> "style =" text-Decoration: none; color: #666666; "target =" _ blank "> reply </a>
<SCRIPT type = "text/JavaScript" Language = "JavaScript">
Function deletemessge (theid, thisobj)
{
Window. Confirm ("are you sure you want to delete this message? ");
Inbox. deletemessage (theid); // Ajax does not need to be deleted
Thisobj. parentelement. parentelement. removenode (true );
}
</SCRIPT>
</Itemtemplate>
3. When the user clicks the close button of the browser, a prompt is displayed before the browser is closed (the content on the current browser page can be viewed) to remind the user that there may be unsaved data.
Function window. onbeforeunload ()
{
If (event. clientx> 360 & event. clienty <0 | event. altkey)
{
Window. event. returnvalue = "";
}
}
4. you have added a pop-up dialog box attribute to the delete button. Can you bring up a different dialog box based on the user login situation: the content of the Unlogged user dialog box is "no permission", and the login user is "Delete "!
Front-end JS
function gocheck (type)
{< br> If (type = 0)
{< br> alert ("no permission"); Return false;
}< br> else return confirm ("Delete! ");
}< br> background. CS
int I;
If (SUID =" "| SUID = NULL | SUID! = UID) {I = 0 ;}< br> else {I = 1 ;}< br> btn_del.attributes.add ("onclick", "Return gocheck_del (" + I. tostring () + ");");
btn_modify.attributes.add ("onclick", "Return gocheck_mod (" + I. tostring () + ");");