Home > Net >  Asp.net, click on the button after confirmation
Asp.net, click on the button after confirmation

Time:11-08

The code below
 
Protected void BtnBookTypeAdd_Click (object sender, EventArgs e)
{
//to iterate through all the control

A decimal max_score=0;
A decimal pf_score=0;
A decimal ckbox_score=0;
A decimal txtbox_score=0;
A decimal zf=0;
Foreach (RepeaterItem c in RpBookType. Items)
{

The CheckBox check=(CheckBox) c.F indControl (" chk_active ");
TextBox txtbox=(TextBox) c.F indControl (" txt_active ");
Label lbl_PFXL_SCORE=(Label) c.F indControl (" lbl_PFXL_SCORE ");
Label lbl_PFDL_NAME=(Label) c.F indControl (" lbl_PFDL_NAME ");
Label lbl_PFXL_NAME=(Label) c.F indControl (" lbl_PFXL_NAME ");
Label lbl_PFDL_ID=(Label) c.F indControl (" lbl_PFDL_ID ");
Label lbl_PFXL_ID=(Label) c.F indControl (" lbl_PFXL_ID ");
Max_score=the Convert. ToDecimal (lbl_PFXL_SCORE. Text. The ToString ());

//do some input legitimacy of judgment

If (DAL. DataOperWj. IsNumric_wj (txtbox. Text. The ToString ())==false)//whether the legal format
{
Common. ShowMessage. Show (Page, "error", "secondary classification" + lbl_PFXL_NAME. Text. The ToString () + "the format of the input error, please check! ");
return;

}

If (txtbox. Text. The ToString (). The Trim (). The IndexOf (' - ') & gt; 1)
{
Common. ShowMessage. Show (Page, "error", "secondary classification" + lbl_PFXL_NAME. Text. The ToString () + "has the illegal characters, please check! ");
return;
}

Pf_score=the Convert. ToDecimal (txtbox. Text. The ToString ());//legal format conversion again


If (pf_score & gt; Max_score & amp; & Txtbox. Visible==true)//is greater than the highest
{
Common. ShowMessage. Show (Page, "error", "secondary classification" + lbl_PFXL_NAME. Text. The ToString () + "column, is greater than the highest score, please check! ");
return;

}




//end of legal inspection, a total score
Txtbox_score=txtbox_score + Convert. ToDecimal (txtbox. Text. The ToString (). The Trim ());
If (check. Checked==true)
{
Ckbox_score=ckbox_score + Convert. ToDecimal (lbl_PFXL_SCORE. Text. The ToString (). The Trim ());
}


}

//total score
Zf=txtbox_score + ckbox_score;

//the front is a series of judgment, traverse the repeater access
//after the take, calculate the total score, confirm whether submitted
Enclosing BtnBookTypeAdd. Attributes. Add (" onclick ", "return confirm (' total score is:" + government + "sure to submit? ');" );
//choice is submitted, you do nothing, as if it can't
//todo write library,

}


CodePudding user response:

To complete some judgment and calculation, calculate a score, and then in the message, to the total score, pop-up confirmation box

CodePudding user response:

There is a problem is to point two button, can pop-up prompts. The third time is normal

CodePudding user response:

Not use registscript?

CodePudding user response:

https://bbs.csdn.net/topics/330152693? List=8450681

CodePudding user response:

https://bbs.csdn.net/topics/360064587

CodePudding user response:

In your code
 enclosing BtnBookTypeAdd. Attributes. The Add (" onclick ", "return confirm (' total score is:" + government + "sure to submit? ') 
here you just a behavior definition to the front end tag, but you did not make this page refresh immediately implement the confirm, and confirm your registration code executed nor will the user submits the information back to specify exactly in the asp.net code controls (a component in the page or pages, controls) to capture the events, in fact your asp.net knowledge here is "upside down", understand programming technology direction is wrong,

CodePudding user response:

 
ClientScript. RegisterStartupScript (GetType (), "confirm", "CallServerMethod (confirm (' total score is:" + zf. ToString () + "submit? '), null);" , true);



I change to this, the realization of the purpose, but also brings a problem,
Confirmation, perform Confirm ()
 
Private string Confirm ()
{
//there are some writing library operations

Binddata ();
//this is binding the operation of the repeater, but found no refresh the data on the repeater,

}


CodePudding user response:

My demand is that the code below
 
Protected void BtnBookTypeAdd_Click (object sender, EventArgs e)
{
//to iterate through all the control

A decimal max_score=0;
A decimal pf_score=0;
A decimal ckbox_score=0;
A decimal txtbox_score=0;
A decimal zf=0;
Foreach (RepeaterItem c in RpBookType. Items)
{

The CheckBox check=(CheckBox) c.F indControl (" chk_active ");
TextBox txtbox=(TextBox) c.F indControl (" txt_active ");
Label lbl_PFXL_SCORE=(Label) c.F indControl (" lbl_PFXL_SCORE ");
Label lbl_PFDL_NAME=(Label) c.F indControl (" lbl_PFDL_NAME ");
Label lbl_PFXL_NAME=(Label) c.F indControl (" lbl_PFXL_NAME ");
Label lbl_PFDL_ID=(Label) c.F indControl (" lbl_PFDL_ID ");
Label lbl_PFXL_ID=(Label) c.F indControl (" lbl_PFXL_ID ");
Max_score=the Convert. ToDecimal (lbl_PFXL_SCORE. Text. The ToString ());

//do some input legitimacy of judgment

If (DAL. DataOperWj. IsNumric_wj (txtbox. Text. The ToString ())==false)//whether the legal format
{
Common. ShowMessage. Show (Page, "error", "secondary classification" + lbl_PFXL_NAME. Text. The ToString () + "the format of the input error, please check! ");
return;

}

If (txtbox. Text. The ToString (). The Trim (). The IndexOf (' - ') & gt; 1)
{
Common. ShowMessage. Show (Page, "error", "secondary classification" + lbl_PFXL_NAME. Text. The ToString () + "has the illegal characters, please check! ");
return;
}

Pf_score=the Convert. ToDecimal (txtbox. Text. The ToString ());//legal format conversion again


If (pf_score & gt; Max_score & amp; & Txtbox. Visible==true)//is greater than the highest
{
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull