[英]How can I convert the following event to javascript?
I am in confusion how to do, is there a way? 我很困惑该怎么办,有办法吗?
Below is my code. 下面是我的代码。 Is there a possible way to call a method inside JavaScript, because I have a method named GetTaxDetails()
in the event. 是否有可能在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");
}
}
Since you want to access objTax that is not accessable for your client until you do a post back, I recommend the asp:UpdatePanel
: 由于您要访问的客户机只有在回发后才能访问的objTax,因此我建议使用asp:UpdatePanel
:
Use the ASP.NET Ajax build-in by wrapping your relating controls into an asp:UpdatePanel
. 通过将相关控件包装到asp:UpdatePanel
中,使用ASP.NET Ajax内置组件。 Make sure to place a asp:ScriptManager
below your <form>
tag, too. 确保还要在<form>
标记下放置一个asp:ScriptManager
。
http://msdn.microsoft.com/library/bb398864(v=vs.100).aspx http://msdn.microsoft.com/library/bb398864(v=vs.100).aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.