我有两个text boxes
个compare validator
控件。但是在回发时,textbox
值会以逗号附加。在编辑模式下,新值将以逗号后跟前一个值。
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
lblClientName.Text = "" + Request.QueryString["clientname"];
BindAddressSheet();
string addrShtId = "" + Request.QueryString["addrshtid"];
hdnAddrSheetId.Value = addrShtId;
if (hdnAddrSheetId.Value!=String.Empty)
{
FillAddressDetails(); //load values on edit mode
}
}
}
public void FillAddressDetails()
{
string addrShtId = "" + Request.QueryString["addrshtid"];
AddrShtBOL objBOL = new AddrShtBOL();
AddrShtBAL objBAL = new AddrShtBAL();
objBOL = objBAL.SelectAddressSheetByID(Util.ToInt(addrShtId));
// the following 2 text boxes retain the values
txtHzntalPostn.Text = objBOL.AddrshtHpos.ToString();
txtVertPostn.Text = objBOL.AddrshtVpos.ToString();
ddlOrientation.SelectedValue = objBOL.AddrshtOrient;
ddlUnitOfMeasure.SelectedValue = objBOL.AddrshtPosUnits;
txtLogoHzntalPostn.Text = objBOL.AddrshtLogoHpos.ToString();
txtLogoVertPostn.Text = objBOL.AddrshtLogoVpos.ToString();
txtLogoName.Text = objBOL.AddrshtLogoNm;
txtAddr1.Text = objBOL.AddrshtRetnAddrIn1;
txtAddr2.Text = objBOL.AddrshtRetnAddrIn2;
txtAddr3.Text = objBOL.AddrshtRetnAddrIn3;
txtAddr4.Text = objBOL.AddrshtRetnAddrIn4;
txtAddr5.Text = objBOL.AddrshtRetnAddrIn5;
txtAddr6.Text = objBOL.AddrshtRetnAddrIn6;
txtRtnAddHzntalPostn.Text = objBOL.AddrshtRetnShtHpos.ToString();
txtRtnAddVertPostn.Text = objBOL.AddrshtRetnShtVpos.ToString();
}
//Button click event
protected void btnSaveAddSheets_Click(object sender, EventArgs e)
{
if (txtHzntalPostn.Text.Trim() == "")
{
ShowMessage("Please enter Horizontal Position");
txtHzntalPostn.Focus();
return;
}
if (txtVertPostn.Text.Trim() == "")
{
ShowMessage("Please enter Vertical Position");
txtVertPostn.Focus();
return;
}
AddrShtBOL BOL = new AddrShtBOL();
AddrShtBAL BAL = new AddrShtBAL();
string clientNo = "" + Request.QueryString["clientno"];
BOL.OmAddrShtId = Util.ToInt(hdnAddrSheetId.Value);
if (BOL.OmAddrShtId > 0)
{
BOL.Action = 4;
}
else
{
BOL.Action = 1;
}
BOL.ClientNo = clientNo;
BOL.AddrShtFmtCd = 0;// addrShtFmtCd;
BOL.AddrshtHpos = Util.ToDecimal(txtHzntalPostn.Text.Trim());
BOL.AddrshtVpos = Util.ToDecimal(txtVertPostn.Text.Trim());
BOL.AddrshtOrient = ddlOrientation.SelectedValue;
BOL.AddrshtPosUnits = ddlUnitOfMeasure.SelectedValue;
BOL.CreatedBy = "" + Request.ServerVariables["LOGON_USER"];
int result = BAL.InsertAddressSheet(BOL);
hdnAddrSheetId.Value = result.ToString();
if (result > 0)
{
lblAddr.Text = "Address Sheet details saved";
BindAddressSheet();
}
if (BOL.Action == 1)
{
hdnAddrSheetId.Value = result.ToString();
lblErr.Visible = false;
}
}
客户端
<div class="form-group col-md-4 col-sm-6">
<label for="description">
H. Pos</label>
<asp:TextBox ID="txtHzntalPostn" runat="server" CssClass="form-control" MaxLength="7"placeholder="0"> </asp:TextBox>
<asp:CompareValidator ID="cmp1" runat="server" ErrorMessage=" <= 999.999" ControlToValidate="txtHzntalPostn"Operator="LessThan" Type="Double" ValueToCompare="1000" Style="font-size: 14px;" ValidationGroup="addrsheet"> </asp:CompareValidator>
</div>