# Region Prevent multiple page submissions
/// <Summary>
/// Whether to prevent users from submitting pages multiple times. The default value is true.
/// If this parameter is set to true, a prompt is displayed when you submit the page to prevent the user from submitting the page again before the server responds.
/// </Summary>
Public Bool Oneclick
{
Get
{
String Key = This . Clientid + " _ Oneclick " ;
If (Viewstate [Key] = Null )
{
Viewstate [Key] = True ;
}
Return ( Bool ) Viewstate [Key];
}
Set
{
String Key = This . Clientid + " _ Oneclick " ;
Viewstate [Key] = Value;
}
}
/// <Summary>
/// Prompt when the form is submitted
/// </Summary>
Protected String Monsubmittip = String . Empty;
Protected String Onsubmittip
{
Set
{
Monsubmittip = Value;
}
Get
{
If (Monsubmittip = "" )
{
If ( This . Curculture = 2052 )
{
Monsubmittip = " Processing Form. Please wait .... " ;
}
Else
{
Monsubmittip = " Form process, please waiting .... " ;
}
}
Return Monsubmittip;
}
}
/// <Summary>
/// Regenerate the HTML header and tail
/// </Summary>
Private Void Rebuildhtml ()
{
# Region Added measures to prevent repeated submission of forms.
IntCurctrl;
IntCount;
Htmlform= Null;
// Add a submission event on Form
For (Curctrl = 0 , Count = This . Controls. Count; curctrl < Count; curctrl ++ )
{
Form = This . Controls [curctrl] As Htmlform;
// Not null
If (Form ! = Null )
{
Break ;
}
}
// return
If (curctrl = count)
{< br> return ;
}
Form. attributes ["Onsubmit"]= "Try {submitform (this);} catch (e ){}";
// Onclick
If ( This . Oneclick)
{
// Add a table with prompt information
Stringbuilder sb = New Stringbuilder ();
SB. append ( " <Table id = \ "show_panel_on_submit \" " );
SB. append ( " Style = \ "position: absolute; display: none ;\" " );
SB. append ( " Border = 0 Height = 100% width = 100%> " );
SB. append ( " \ N <tr> " );
SB. append ( " \ N <TD align = center> " );
SB. append (onsubmittip );
SB. append ( " \ N </TD> " );
SB. append ( " \ N </tr> " );
SB. append ( " </Table> " );
(Literalcontrol) controls [ 0 ]). Text + = SB. tostring ();
// Added a script to hide the form and display the prompt table when the form is submitted.
// Note: whether a script event is performed depends on whether the page verification control content is empty.
Sb = New Stringbuilder ();
SB. append ( " \ N <SCRIPT> " );
SB. append ( " \ Nfunction submitform (form ){ " );
SB. append ( " \ N if (document. All. validation_summary_on_form_submit.innerhtml = ''){ " );
SB. append ( " \ N form. style. Display = 'none '; " );
SB. append ( " \ N document. All. show_panel_on_submit.style.display = ''; " );
SB. append ( " \ N} " );
SB. append ( " \ N} " );
SB. append ( " \ N </SCRIPT> " );
(Literalcontrol) controls [ 2 ]). Text + = SB. tostring ();
// Added the page verification control,
// When submitting a form, you can check the innerhtml control to determine whether the submission is legal.
Validationsummary = New Validationsummary ();
Vs. ID = " Validation_summary_on_form_submit " ;
Vs. attributes [ " Style " ] = " Position: absolute; top:-1000; left:-1000 " ;
Form. Controls. Add ();
}
# Endregion
}
// Modify record 2 2010-09-14 Zhu Jie add rebuildhtml (), whether to prevent the user from submitting the page multiple times
# Endregion