[Import] Sunday learning records

Source: Internet
Author: User

1. Click Cancel to delete the corresponding row.
2. In the Add row function, add a variable to make it equal to the newly added row each time. In the rowUpdate event, set the row to edit if it is the newly added row.
3. In the rowedit event, if editindex is not-1, check whether the row value is valid. If the row value is valid, it can be canceled. If the row value is invalid, it cannot be executed.

4. Deleted authenticated javascript
5. Xiaoqiang: If you want to use two pages, use the second page.
ShowModalDialog () (IE 4 + supported)
ShowModelessDialog () (IE 5 + supported)
The window. showModalDialog () method is used to create a modal dialog box that displays HTML content.
The window. showModelessDialog () method is used to create a non-modal dialog box that displays HTML content.

MyDeleteButton. Attributes. Add ("onclick", "return confirm ('you really want to delete "_
+ E. Item. ItemIndex. ToString + "OK? ');")

6. Regular Expression ^ \ d + (\. \ d [2])? $

Appendix 1:
1) Simple

To add an authentication script to a button, you can

<% @ Page Language = "C #" %>

<SCRIPT language = "javascript">

 

Function getconfirm ()

{

If (confirm ("Do you want to delete record? ") = True)

Return true;

Else

Return false;

 

}

</SCRIPT>

 

<Script runat = "server">

Public void Page_Load (Object sender, EventArgs E ){

BtnSubmit. Attributes. Add ("onclick", "return getconfirm ();");

}

Void btnSubmit_Click (object sender, EventArgs e ){

Message. Text = "You entered your name as:" + txtName. Text;

}

</Script>

<Html>

<Head>

</Head>

<Body>

<Form runat = "server">

Name: <asp: Textbox id = "txtName" runat = "server"/>

<Asp: Button id = "btnSubmit" onclick = "btnSubmit_Click" runat = "server" Text = "Submit"> </asp: Button> <br/>

<Asp: Label id = "Message" runat = "server"/>

</Form>

</Body>

</Html>

Note the key points btnSubmit. attributes. add ("onclick", "return fffkkk ();"); this statement is equivalent to adding "onclick =" return fffkkk (); "to the static page tag.

2) more complex

Sometimes we need to add authentication in the delete column of the DataGrid.

First, create a DataGrid and add a delete column to her.

 

 

 

<Asp: DataGrid id = "DataGrid1" runat = "server">

<Columns>

<Asp: TemplateColumn>

<ItemTemplate>

<Asp: LinkButton id = "mongodel"

Runat = "server" Text = "Delete"

CommandName = "Delete" CausesValidation = "false">

</Asp: LinkButton>

</ItemTemplate>

</Asp: TemplateColumn>

</Columns>

</Asp: DataGrid>

 

Then write in the ItemDataBound event of the DataGrid as follows:

 

Private Sub DataGrid1_ItemDataBound

(ByVal sender As Object, ByVal e As DataGridItemEventArgs)

Handles DataGrid1.ItemDataBound

Dim l As LinkButton

If e. Item. ItemType = ListItemType. Item Or

E. Item. ItemType = ListItemType. AlternatingItem Then

L = CType (e. Item. Cells (0). FindControl ("mongodel"), LinkButton)

L. Attributes. Add ("onclick", "return getconfirm ();")

End If

End Sub

The Getconfirm () function is the same as the first one.

Function getconfirm ()

{

If (confirm ("Do you want to delete record? ") = True)

Return true;

Else

Return false;

}

In this way, you can.

Appendix 2:
ShowModalDialog () (IE 4 + supported)
ShowModelessDialog () (IE 5 + supported)
The window. showModalDialog () method is used to create a modal dialog box that displays HTML content.
The window. showModelessDialog () method is used to create a non-modal dialog box that displays HTML content.

Usage:
VReturnValue = window. showModalDialog (sURL [, vArguments] [, sFeatures])
VReturnValue = window. showModelessDialog (sURL [, vArguments] [, sFeatures])

Parameter description:
SURL --
Required parameter. Type: string. Specifies the URL of the document to be displayed in the dialog box.
VArguments --
Optional parameter; Type: variant. Used to pass parameters to the dialog box. The passed parameter types are not limited, including arrays. The dialog box uses window. dialogArguments to obtain the passed parameters.
SFeatures --
Optional parameter; Type: String. Used to describe the appearance and other information of the dialog box. You can use one or more of the following, separated by semicolons.
1. dialogHeight: the dialog box height. The default unit of dialogHeight and dialogWidth in IE4 is em, while that in IE5 is px. For convenience, when defining the modal mode dialog box, unit with px.
2. dialogWidth: Dialog Box width.
3. dialogLeft: the distance from the left of the screen.
4. dialogTop: the distance from the screen.
5. center: {yes | no | 1 | 0}: whether the window is centered. The default value is yes, but the height and width can still be specified.
6. help: {yes | no | 1 | 0}: whether to display the help button. The default value is yes.
7. resizable: {yes | no | 1 | 0} [IE5 +]: whether the size can be changed. No by default.
8. status: {yes | no | 1 | 0} [IE5 +]: whether to display the status bar. The default value is yes [Modeless] or no [Modal].
9. scroll: {yes | no | 1 | 0 | on | off}: Specifies whether the scroll bar is displayed in the dialog box. The default value is yes.
The following attributes are used in HTA and are not used in general web pages.
10. dialogHide: {yes | no | 1 | 0 | on | off}: whether the dialog box is hidden when printing or previewing. The default value is no.
11. edge: {sunken | raised}: Specify the border style of the dialog box. The default value is raised.
12. unadorned: {yes | no | 1 | 0 | on | off}: no by default.

Parameter transfer:
1. vArguments is used to pass Parameters in the dialog box. The type is not limited. For string types, the maximum value is 4096 characters. Objects can also be passed, for example:

-------------------------------
Parent.htm
<Script>
Var obj = new Object ();
Obj. name = "51js ";
Window. showModalDialog ("modal.htm", obj, "dialogWidth = 200px; dialogHeight = 100px ");
</Script>
Modal.htm
<Script>
Var obj = window. dialogArguments
Alert ("the parameter you passed is:" + obj. name)
</Script>
-------------------------------
2. You can use window. returnValue to return information to the window that opens the dialog box. It can also be an object. For example:
------------------------------
Parent.htm
<Script>
Str = window. showModalDialog ("modal.htm", "dialogWidth = 200px; dialogHeight = 100px ");
Alert (str );
</Script>
Modal.htm
<Script>
Window. returnValue = http://www.bypro.net;
</Script>

I. Windows. open () support environment: JavaScript1.0 +/JScript1.0 +/Nav2 +/IE3 +/Opera3 +

Ii. Basic Syntax:
Window. open (pageURL, name, parameters)
Where:
PageURL is the sub-window path
Name is the sub-window handle
Parameters is window parameters (parameters are separated by commas)

Iii. Example:
<SCRIPT>
<! --
Window. open ('page.html ', 'newwindow', 'height = 100, width = 400, top = 0, left = 0, toolbar = no, menubar = no, scrollbars = no, resizable = no, location = no, status = no ')
// Write a row
-->
</SCRIPT>
After running the script, page.html will be opened in the newwindow of the new form, with a width of 100 and a height of 400. It is 0 pixels away from the screen top, 0 pixels left, no tool bar, no menu bar, no scroll bar, and cannot be adjusted, no address bar, no status bar.
Please compare.

In the preceding example, several common parameters are involved. In addition, there are many other parameters. For details, see section 4.
Iv. Parameters
Here, yes/no can also use 1/0; pixel value is a specific value, in pixels.

Parameter | value range | description
|
AlwaysLowered | yes/no | specifies that the window is hidden behind all windows
AlwaysRaised | yes/no | specify that the window is suspended above all windows
Depended | yes/no | whether to close the parent window at the same time
Directories | yes/no | whether the directory bar of Nav2 and 3 is visible
Height | pixel value | window height
Hotkeys | yes/no | set the Security Exit hotkey in the window without menu bar
InnerHeight | pixel value | pixel height of the document in the window
InnerWidth | pixel value | pixel width of the document in the window
Location | yes/no | whether the location bar is visible
Menubar | yes/no | whether the menu bar is visible
OuterHeight | pixel value | set the pixel height of the window (including the decorative border)
OuterWidth | pixel value | set the pixel width of the window (including the decorative border)
Resizable | yes/no | whether the window size can be adjusted
ScreenX | pixel value | pixel length between the window and the left boundary of the screen
ScreenY | pixel value | pixel length between the window and the upper boundary of the screen
Scrollbars | yes/no | whether the window has a scroll bar
Titlebar | yes/no | whether the title bar of the window is visible
Toolbar | yes/no | whether the toolbar of the window is visible
Width | pixel value | pixel Width of the window
Z-look | yes/no | whether the window floated above other windows after being activated

Returns the interval between two dates.
Syntax
DateDiff (interval, date1, date2 [, firstdayofweek [, firstweekofyear])
The syntax of the DateDiff function includes the following parameters:

Parameter description
Interval is required. String expression indicates the time interval between date1 and date2. For values, see the "Settings" section.
Date1 and date2 are required. Date expression. Two dates used for calculation.
Firstdayofweek is optional. Specify the constant of the first day of the week. If not specified, the default value is Sunday. For values, see the "Settings" section.
Firstweekofyear is optional. Specifies the constant of the first week of a year. If this parameter is not specified, the default value is the week of April 1, January 1. For values, see the "Settings" section.

Set
The interval parameter can have the following values:
Set description
Yyyy
Q quarter
N months
Y number of days in a year
D
Number of days per week
Ww week
H hour
M minutes
S seconds

The firstdayofweek parameter can have the following values:

Constant Value description
VbUseSystem 0 is set using the regional language (NLS) API.
VbSunday 1 Sunday (default)
VbMonday 2 Monday
VbTuesday 3 Tuesday
VbWednesday 4
VbThursday 5 Thursday
VbFriday 6 Friday
VbSaturday 7 Saturday

The firstweekofyear parameter can have the following values:

Constant Value description
VbUseSystem 0 is set using the regional language (NLS) API.
VbFirstJan1 starts from the week of July 1, January 1 (default ).
VbFirstFourDays 2 starts from the first week of at least four days in the New Year.
VbFirstFullWeek 3 starts from the first complete week of the year.

Description
The DateDiff function is used to determine the number of specified time intervals between two dates. For example, you can use DateDiff to calculate the number of days with different dates, or the number of weeks between the day and the last day of the current year.
To calculate the number of days for date1 and date2, you can use "number of days in a year" ("y") or "day" ("d "). When interval is "the number of days of a week" ("w"), DateDiff returns the number of weeks between two dates. If date1 is Monday, DateDiff calculates the number of Monday before date2. This result contains date2, not date1. If interval is "Week" ("ww"), the DateDiff function returns the number of weeks between two dates in the calendar table. Function compute the number of Sundays between date1 and date2. If date2 is Sunday, DateDiff calculates date2, but date1 is not calculated even if date1 is Sunday.

If date1 is later than date2, The DateDiff function returns a negative number.

The firstdayofweek parameter affects the calculation of the "w" and "ww" separators.

If date1 or date2 is a date text, the specified year will become a fixed part of the date. However, if date1 or date2 is included in quotation marks ("") and the year is omitted, the current year will be inserted every time date1 or date2 expressions are calculated in the code. In this way, you can write program code for different years.

When interval is "year" ("yyyy"), although only one day is actually different from January 1, DateDiff returns 1, indicating that the year is different.

The following example uses the DateDiff function to display the number of days between today and the given date:

Function DiffADate (theDate)
DiffADate = "days from the current day:" & DateDiff ("d", Now, theDate)
End Function

 

1. Click Cancel to delete the corresponding row.
2. In the Add row function, add a variable to make it equal to the newly added row each time. In the rowUpdate event, set the row to edit if it is the newly added row.
3. In the rowedit event, if editindex is not-1, check whether the row value is valid. If the row value is valid, it can be canceled. If the row value is invalid, it cannot be executed.

4. Deleted authenticated javascript
5. Xiaoqiang: If you want to use two pages, use the second page.
ShowModalDialog () (IE 4 + supported)
ShowModelessDialog () (IE 5 + supported)
The window. showModalDialog () method is used to create a modal dialog box that displays HTML content.
The window. showModelessDialog () method is used to create a non-modal dialog box that displays HTML content.

MyDeleteButton. Attributes. Add ("onclick", "return confirm ('you really want to delete "_
+ E. Item. ItemIndex. ToString + "OK? ');")

6. Regular Expression ^ \ d + (\. \ d [2])? $

Appendix 1:
1) Simple

To add an authentication script to a button, you can

<% @ Page Language = "C #" %>

<SCRIPT language = "javascript">

 

Function getconfirm ()

{

If (confirm ("Do you want to delete record? ") = True)

Return true;

Else

Return false;

 

}

</SCRIPT>

 

<Script runat = "server">

Public void Page_Load (Object sender, EventArgs E ){

BtnSubmit. Attributes. Add ("onclick", "return getconfirm ();");

}

Void btnSubmit_Click (object sender, EventArgs e ){

Message. Text = "You entered your name as:" + txtName. Text;

}

</Script>

<Html>

<Head>

</Head>

<Body>

<Form runat = "server">

Name: <asp: Textbox id = "txtName" runat = "server"/>

<Asp: Button id = "btnSubmit" onclick = "btnSubmit_Click" runat = "server" Text = "Submit"> </asp: Button> <br/>

<Asp: Label id = "Message" runat = "server"/>

</Form>

</Body>

</Html>

Note the key points btnSubmit. attributes. add ("onclick", "return fffkkk ();"); this statement is equivalent to adding "onclick =" return fffkkk (); "to the static page tag.

2) more complex

Sometimes we need to add authentication in the delete column of the DataGrid.

First, create a DataGrid and add a delete column to her.

 

 

 

<Asp: DataGrid id = "DataGrid1" runat = "server">

<Columns>

<Asp: TemplateColumn>

<ItemTemplate>

<Asp: LinkButton id = "mongodel"

Runat = "server" Text = "Delete"

CommandName = "Delete" CausesValidation = "false">

</Asp: LinkButton>

</ItemTemplate>

</Asp: TemplateColumn>

</Columns>

</Asp: DataGrid>

 

Then write in the ItemDataBound event of the DataGrid as follows:

 

Private Sub DataGrid1_ItemDataBound

(ByVal sender As Object, ByVal e As DataGridItemEventArgs)

Handles DataGrid1.ItemDataBound

Dim l As LinkButton

If e. Item. ItemType = ListItemType. Item Or

E. Item. ItemType = ListItemType. AlternatingItem Then

L = CType (e. Item. Cells (0). FindControl ("mongodel"), LinkButton)

L. Attributes. Add ("onclick", "return getconfirm ();")

End If

End Sub

The Getconfirm () function is the same as the first one.

Function getconfirm ()

{

If (confirm ("Do you want to delete record? ") = True)

Return true;

Else

Return false;

}

In this way, you can.

Appendix 2:
ShowModalDialog () (IE 4 + supported)
ShowModelessDialog () (IE 5 + supported)
The window. showModalDialog () method is used to create a modal dialog box that displays HTML content.
The window. showModelessDialog () method is used to create a non-modal dialog box that displays HTML content.

Usage:
VReturnValue = window. showModalDialog (sURL [, vArguments] [, sFeatures])
VReturnValue = window. showModelessDialog (sURL [, vArguments] [, sFeatures])

Parameter description:
SURL --
Required parameter. Type: string. Specifies the URL of the document to be displayed in the dialog box.
VArguments --
Optional parameter; Type: variant. Used to pass parameters to the dialog box. The passed parameter types are not limited, including arrays. The dialog box uses window. dialogArguments to obtain the passed parameters.
SFeatures --
Optional parameter; Type: String. Used to describe the appearance and other information of the dialog box. You can use one or more of the following, separated by semicolons.
1. dialogHeight: the dialog box height. The default unit of dialogHeight and dialogWidth in IE4 is em, while that in IE5 is px. For convenience, when defining the modal mode dialog box, unit with px.
2. dialogWidth: Dialog Box width.
3. dialogLeft: the distance from the left of the screen.
4. dialogTop: the distance from the screen.
5. center: {yes | no | 1 | 0}: whether the window is centered. The default value is yes, but the height and width can still be specified.
6. help: {yes | no | 1 | 0}: whether to display the help button. The default value is yes.
7. resizable: {yes | no | 1 | 0} [IE5 +]: whether the size can be changed. No by default.
8. status: {yes | no | 1 | 0} [IE5 +]: whether to display the status bar. The default value is yes [Modeless] or no [Modal].
9. scroll: {yes | no | 1 | 0 | on | off}: Specifies whether the scroll bar is displayed in the dialog box. The default value is yes.
The following attributes are used in HTA and are not used in general web pages.
10. dialogHide: {yes | no | 1 | 0 | on | off}: whether the dialog box is hidden when printing or previewing. The default value is no.
11. edge: {sunken | raised}: Specify the border style of the dialog box. The default value is raised.
12. unadorned: {yes | no | 1 | 0 | on | off}: no by default.

Parameter transfer:
1. vArguments is used to pass Parameters in the dialog box. The type is not limited. For string types, the maximum value is 4096 characters. Objects can also be passed, for example:

-------------------------------
Parent.htm
<Script>
Var obj = new Object ();
Obj. name = "51js ";
Window. showModalDialog ("modal.htm", obj, "dialogWidth = 200px; dialogHeight = 100px ");
</Script>
Modal.htm
<Script>
Var obj = window. dialogArguments
Alert ("the parameter you passed is:" + obj. name)
</Script>
-------------------------------
2. You can use window. returnValue to return information to the window that opens the dialog box. It can also be an object. For example:
------------------------------
Parent.htm
<Script>
Str = window. showModalDialog ("modal.htm", "dialogWidth = 200px; dialogHeight = 100px ");
Alert (str );
</Script>
Modal.htm
<Script>
Window. returnValue = http://www.bypro.net;
</Script>

I. Windows. open () support environment: JavaScript1.0 +/JScript1.0 +/Nav2 +/IE3 +/Opera3 +

Ii. Basic Syntax:
Window. open (pageURL, name, parameters)
Where:
PageURL is the sub-window path
Name is the sub-window handle
Parameters is window parameters (parameters are separated by commas)

Iii. Example:
<SCRIPT>
<! --
Window. open ('page.html ', 'newwindow', 'height = 100, width = 400, top = 0, left = 0, toolbar = no, menubar = no, scrollbars = no, resizable = no, location = no, status = no ')
// Write a row
-->
</SCRIPT>
After running the script, page.html will be opened in the newwindow of the new form, with a width of 100 and a height of 400. It is 0 pixels away from the screen top, 0 pixels left, no tool bar, no menu bar, no scroll bar, and cannot be adjusted, no address bar, no status bar.
Please compare.

In the preceding example, several common parameters are involved. In addition, there are many other parameters. For details, see section 4.
Iv. Parameters
Here, yes/no can also use 1/0; pixel value is a specific value, in pixels.

Parameter | value range | description
|
AlwaysLowered | yes/no | specifies that the window is hidden behind all windows
AlwaysRaised | yes/no | specify that the window is suspended above all windows
Depended | yes/no | whether to close the parent window at the same time
Directories | yes/no | whether the directory bar of Nav2 and 3 is visible
Height | pixel value | window height
Hotkeys | yes/no | set the Security Exit hotkey in the window without menu bar
InnerHeight | pixel value | pixel height of the document in the window
InnerWidth | pixel value | pixel width of the document in the window
Location | yes/no | whether the location bar is visible
Menubar | yes/no | whether the menu bar is visible
OuterHeight | pixel value | set the pixel height of the window (including the decorative border)
OuterWidth | pixel value | set the pixel width of the window (including the decorative border)
Resizable | yes/no | whether the window size can be adjusted
ScreenX | pixel value | pixel length between the window and the left boundary of the screen
ScreenY | pixel value | pixel length between the window and the upper boundary of the screen
Scrollbars | yes/no | whether the window has a scroll bar
Titlebar | yes/no | whether the title bar of the window is visible
Toolbar | yes/no | whether the toolbar of the window is visible
Width | pixel value | pixel Width of the window
Z-look | yes/no | whether the window floated above other windows after being activated

Returns the interval between two dates.
Syntax
DateDiff (interval, date1, date2 [, firstdayofweek [, firstweekofyear])
The syntax of the DateDiff function includes the following parameters:

Parameter description
Interval is required. String expression indicates the time interval between date1 and date2. For values, see the "Settings" section.
Date1 and date2 are required. Date expression. Two dates used for calculation.
Firstdayofweek is optional. Specify the constant of the first day of the week. If not specified, the default value is Sunday. For values, see the "Settings" section.
Firstweekofyear is optional. Specifies the constant of the first week of a year. If this parameter is not specified, the default value is the week of April 1, January 1. For values, see the "Settings" section.

Set
The interval parameter can have the following values:
Set description
Yyyy
Q quarter
N months
Y number of days in a year
D
Number of days per week
Ww week
H hour
M minutes
S seconds

The firstdayofweek parameter can have the following values:

Constant Value description
VbUseSystem 0 is set using the regional language (NLS) API.
VbSunday 1 Sunday (default)
VbMonday 2 Monday
VbTuesday 3 Tuesday
VbWednesday 4
VbThursday 5 Thursday
VbFriday 6 Friday
VbSaturday 7 Saturday

The firstweekofyear parameter can have the following values:

Constant Value description
VbUseSystem 0 is set using the regional language (NLS) API.
VbFirstJan1 starts from the week of July 1, January 1 (default ).
VbFirstFourDays 2 starts from the first week of at least four days in the New Year.
VbFirstFullWeek 3 starts from the first complete week of the year.

Description
The DateDiff function is used to determine the number of specified time intervals between two dates. For example, you can use DateDiff to calculate the number of days with different dates, or the number of weeks between the day and the last day of the current year.
To calculate the number of days for date1 and date2, you can use "number of days in a year" ("y") or "day" ("d "). When interval is "the number of days of a week" ("w"), DateDiff returns the number of weeks between two dates. If date1 is Monday, DateDiff calculates the number of Monday before date2. This result contains date2, not date1. If interval is "Week" ("ww"), the DateDiff function returns the number of weeks between two dates in the calendar table. Function compute the number of Sundays between date1 and date2. If date2 is Sunday, DateDiff calculates date2, but date1 is not calculated even if date1 is Sunday.

If date1 is later than date2, The DateDiff function returns a negative number.

The firstdayofweek parameter affects the calculation of the "w" and "ww" separators.

If date1 or date2 is a date text, the specified year will become a fixed part of the date. However, if date1 or date2 is included in quotation marks ("") and the year is omitted, the current year will be inserted every time date1 or date2 expressions are calculated in the code. In this way, you can write program code for different years.

When interval is "year" ("yyyy"), although only one day is actually different from January 1, DateDiff returns 1, indicating that the year is different.

The following example uses the DateDiff function to display the number of days between today and the given date:

Function DiffADate (theDate)
DiffADate = "days from the current day:" & DateDiff ("d", Now, theDate)
End Function

 

]>
Source: http://blog.yesky.com/blog/xioxu/archive/2006/06/25/1459332.html

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.