如何将以下事件转换为javascript
本文关键字:转换 javascript 事件 | 更新日期: 2023-09-27 18:01:10
我很困惑该怎么办,有办法吗?
下面是我的代码。有没有可能在JavaScript中调用方法,因为我在事件中有一个名为GetTaxDetails()
的方法。
protected void ddlTaxCode_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
decimal taxvalue = 0;
decimal rate = 0;
if (txtRate.Text != "")
{
rate = Convert.ToDecimal(txtRate.Text);
}
string Taxcode = ddlTaxCode.SelectedValue.ToString();
DataSet dsTaxDetails = new DataSet();
objTax.TXCode = Taxcode;
dsTaxDetails = objTax.GetTaxDetails();
txtCalcType.Text = dsTaxDetails.Tables[0].Rows[0][4].ToString();
decimal IncludeValue = Convert.ToDecimal(dsTaxDetails.Tables[0].Rows[0][3].ToString());
string Calculation = Session["TaxCalcType"].ToString();
if (Calculation == "Exclude")
{
txtValue.Text = IncludeValue.ToString();
if (txtCalcType.Text == "P-Perc")
{
taxvalue = IncludeValue * (rate / 100);
}
else
{
taxvalue = IncludeValue;
}
txtTaxValue.Text = taxvalue.ToString();
txtItemRate.Text = (taxvalue + rate).ToString();
}
else
{
decimal IncludedTaxValue = (100 + IncludeValue) / 100;
txtValue.Text = IncludedTaxValue.ToString();
if (txtCalcType.Text == "P-Perc")
{
taxvalue = rate - (rate / IncludedTaxValue);
}
else
{
taxvalue = IncludeValue;
}
txtTaxValue.Text = taxvalue.ToString();
txtItemRate.Text = (rate - taxvalue).ToString();
}
}
catch (Exception)
{
Response.Redirect("Error.aspx");
}
}
由于您想要访问objTax,而在您回邮之前,您的客户无法访问该objTay,因此我建议使用asp:UpdatePanel
:
通过将相关控件包装到asp:UpdatePanel
中来使用ASP.NET Ajax内建。确保在<form>
标签下方也放置一个asp:ScriptManager
。
http://msdn.microsoft.com/library/bb398864(v=vs.100(.aspx