Hello, I'm facing a boring problem, as I have a function on a page to cancel weighing. Weighing Why this page is an application that works internally by communicating with a balance over the network, collecting what is being weighed or not.
When I click the button that should close the grid on which it is located, keeping only one primary grid to select the product to be weighed, it does not fire unless I click many times.
This is the part of the code where a timer that runs in is located, picking the value accurately:
<div id="divBalance" runat="server" class="floating-box-inside" style="width: auto;">
<asp:ScriptManager ID="updPanScrMan" runat="server"></asp:ScriptManager>
<asp:Timer ID="OIVTimer" runat="server" Interval="50" OnTick="OIVTimer_Tick" Enabled="false"></asp:Timer>
<asp:UpdateProgress runat="server" ID="updProgress">
<ProgressTemplate>
<div class="loader" style="width: 10px; height: 10px;"></div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="upPnlBalance" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="OIVTimer" EventName="Tick" />
<asp:PostBackTrigger ControlID="btnConfirmarPesagemOIV" />
<asp:PostBackTrigger ControlID="btnCancelarPesagemOIV" />
</Triggers>
<ContentTemplate>
<asp:Table runat="server" ID="tblupBalance" Style="text-align: center;">
<asp:TableRow>
<asp:TableCell>
<asp:DropDownList ID="ddlupBalance" runat="server" OnSelectedIndexChanged="ddlupBalance_SelectedIndexChanged" AutoPostBack="true" CssClass="txt_cssclass" Width="200px" Height="30px" Style="margin: 10px 0px 5px 0px;">
<asp:ListItem> </asp:ListItem>
</asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label ID="lblScaleAmount" runat="server" Text="<%$ Resources:LAnguageStrings, lblScaleAmount %>" CssClass="lbl_cssclass" Style="text-align: center; font-size: larger; margin: 5px 0px 5px 0px;" Width="200px" Height="30px"></asp:Label>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:TextBox ID="txtlblScaleAmount" runat="server" Enabled="False" CssClass="txt_cssclass" Style="text-align: center; font-size: x-large; margin: 5px 0px 5px 0px;" Width="200px" Height="40px"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:Panel runat="server">
<asp:Table runat="server">
<asp:TableRow>
<asp:TableCell>
<asp:Button runat="server" ID="btnConfirmarPesagemOIV" Text="<%$ Resources:LanguageStrings, btnConfirm %>" CssClass="btn btn-primary" Style="width: 200px; height: 30px; margin: 5px 0px 5px 0px;" OnClick="btnConfirmarPesagemOIV_Click" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Button runat="server" ID="btnCancelarPesagemOIV" Text="<%$ Resources:LanguageStrings, btnCancel %>" CssClass="btn btn-default" Style="width: 200px; height: 30px; margin: 5px 0px 10px 0px;" OnClick="btnCancelarPesagemOIV_Click" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
This is the code executed by the button that should stop the timer, close the connection and close the screen grid:
protected void btnCancelarPesagemOIV_Click(object sender, EventArgs e)
{
divAmountsOneIngre.Attributes.Add("style", "display: none");
divBalance.Attributes.Add("style", "display: none");
OIVTimer.Enabled = false;
Session["ScaleConn"] = null;
txtlblScaleAmount.Enabled = false;
txtlblScaleAmount.Text = "";
txtlblScaleAmount.CssClass = "txt_cssclass";
SSCC_barcodeReader.Enabled = false;
SSCC_barcodeReader.Text = "";
txtlblMtrCod.Text = "";
txtlblMtrNam.Text = "";
txtlblLotID.Text = "";
txtlblLotIDQtd.Text = "";
txtlblExpDat.Text = "";
txtlblMax.Text = "";
txtlblTar.Text = "";
txtlblMin.Text = "";
txtlblAct.Text = "";
txtlblRequired.Text = "";
}
I have already searched for thousands of solutions and have yet to find any solution to this or any other way I can accomplish this.
Remembering: When you click the button that should close the grid in just one click, even with some delay, it does not. Unless I click the button several times.
This is the code I use within Timer_Tick ():
protected void OIVTimer_Tick(object sender, EventArgs e)
{
var AmRepo = Session["Material"] as Conaprole_DosimetrySystem.Class.Material;
var ScaleObj = Session["ScaleConn"] as Conaprole_DosimetrySystem.Class.Scale;
if (ScaleObj == null)
{
OIVTimer.Enabled = false;
Session.Remove("ScaleConn");
divAmountsOneIngre.Attributes.Add("style", "display: none");
divBalance.Attributes.Add("style", "display: none");
txtlblScaleAmount.Enabled = false;
txtlblScaleAmount.Text = "";
txtlblScaleAmount.CssClass = "txt_cssclass";
SSCC_barcodeReader.Enabled = true;
SSCC_barcodeReader.Text = "";
btnAddToTotal.Enabled = false;
btnAddToTotal.Visible = false;
btnScaleOn.Enabled = false;
btnScaleOn.Visible = false;
btnFinalize.Enabled = false;
btnFinalize.Visible = false;
btnManualConfirm.Enabled = false;
btnManualConfirm.Visible = false;
btnCancel.Enabled = false;
btnCancel.Visible = false;
btnConfirm.Enabled = false;
btnConfirm.Visible = false;
txtlblMtrCod.Text = "";
txtlblMtrNam.Text = "";
txtlblLotID.Text = "";
txtlblLotIDQtd.Text = "";
txtlblExpDat.Text = "";
txtlblMax.Text = "";
txtlblTar.Text = "";
txtlblMin.Text = "";
txtlblAct.Text = "";
txtlblRequired.Text = "";
btnHide();
}
else
{
float Max = AmRepo.MaxAmount - AmRepo.ActualAmount;
float Min = AmRepo.MinAmount - AmRepo.ActualAmount;
int returnCode = ScaleObj.commandLv0_SI();
if (returnCode == 0)
{
double peso = ScaleObj.weight;
txtlblScaleAmount.Text = String.Format("{0:F3}", peso);
if (peso <= 0f)
{
btnConfirmarPesagemOIV.Enabled = false;
txtlblScaleAmount.CssClass = "txt_cssclass_scale_red";
}
else if (Min <= AmRepo.ContainerTotalAmount)
{
if (peso >= Min || peso <= Max)
{
if (peso < Min && peso >= 0f)
{
btnConfirmarPesagemOIV.Enabled = true;
txtlblScaleAmount.CssClass = "txt_cssclass_scale_red";
}
else if (peso > Max && peso >= 0f)
{
btnConfirmarPesagemOIV.Enabled = false;
txtlblScaleAmount.CssClass = "txt_cssclass_scale_red";
}
else
{
btnConfirmarPesagemOIV.Enabled = true;
txtlblScaleAmount.CssClass = "txt_cssclass_scale_green";
}
}
else
{
btnConfirmarPesagemOIV.Enabled = false;
txtlblScaleAmount.CssClass = "txt_cssclass_scale_red";
}
}
else
{
btnConfirmarPesagemOIV.Enabled = true;
txtlblScaleAmount.CssClass = "txt_cssclass_scale_red";
}
}
else
{
switch (returnCode)
{
case -1:
txtlblScaleAmount.Text = Resources.LanguageStrings.lblScaleOverload;
break;
case -2:
txtlblScaleAmount.Text = Resources.LanguageStrings.lblScaleUnderload;
break;
case -3:
txtlblScaleAmount.Text = Resources.LanguageStrings.lblScaleBusy;
break;
case -4:
txtlblScaleAmount.Text = Resources.LanguageStrings.lblCantWrite;
break;
case -5:
txtlblScaleAmount.Text = Resources.LanguageStrings.lblCantRead;
break;
}
}
}
}
I know it seems to be up to repetitive some things inside it, but some were needed others were out of desperation. And also this code was made by me and another colleague while I was on vacation. It was working, but in the implementation, I encountered some errors. One of these is the one I tell you and I need to solve.