我已经在 aspx.cs 文件中编写了我的 webmethod,但是当我在同一页面中调用 n.Nautilus() 方法时,我无法在 Nautilus() 中获取服务器端控件,在此方法中控件变为 NULL,请查找原因并尽快解决这个问题。
[WebMethod]
public static string Execute4()
{
NewQuote2 n = new NewQuote2();
JavaScriptSerializer j = new JavaScriptSerializer();
string r = string.Empty;
var o = Observable.Start(() =>
{
// Thread.Sleep(7000);
PennStar pn = new PennStar();
r = j.Serialize(new { res = n.Nautilus() });
}, Scheduler.NewThread);
o.First();
// r = n.Nautilus();
return r;
}
public string Nautilus()
{
try
{
if (ddlLineCode.SelectedItem.Value == "GL")
{
deductible = Convert.ToInt32(ddlGLdeductible.SelectedItem.Text);
//ClassCode = Convert.ToInt32(ddlClassCode1.SelectedValues.ToString());
ClassCode = Convert.ToInt32(ddlClasscode.SelectedValue);
}
else if (ddlLineCode.SelectedItem.Value == "PP" || ddlLineCode.SelectedItem.Value == "PR")
{
deductible = Convert.ToInt32(ddlPropdeductible.SelectedValue);
}
string T = ddlTerritory.SelectedItem.Text;
QMSRatingEngine.Nautilus QR = new QMSRatingEngine.Nautilus();
ArrayList Result = new ArrayList();
if (LC == "GL")
{
QMSRatingEngine.NautilusAgents.ReturnGLRate gl = QR.GLRateObject(state, ED, deductible, ClassCode, ddlLimit.SelectedItem.Text, T);
Result.Add(gl);
getNautilusRatedata(gl);//this method code i can write the bellow
}
if (LC == "PP" || LC == "PR")
{
QMSRatingEngine.NautilusAgents.ReturnPropRate PRop = QR.PropertyRateObject(state, ED, ddlPropFormtype.SelectedItem.Text, ddlPropconstructiontype.SelectedItem.Text, ddlPropcovergetype.SelectedItem.Text, deductible, ddlPropuwscale.SelectedItem.Text, ddlPropprotectionclass.SelectedItem.Text, T);
Result.Add(PRop);
}
}
return lbltext.Text;
}
private void getNautilusRatedata(QMSRatingEngine.NautilusAgents.ReturnGLRate gl)
{
lblNautilusPremiumbasis.Text = GetPremiumBasisFormat(txtExposure.Text);
lblNautilusDeductible.Text = getCurrencyFormat(ddlGLdeductible.SelectedItem.Text);
string Type = ddlPremiumBasis.SelectedItem.Text;
decimal Premium = Convert.ToDecimal(gl.BaseRate_Prem.ToString());
decimal nautilusPremiumBasis = Convert.ToDecimal(txtExposure.Text);
decimal Prod = Convert.ToDecimal(gl.BaseRate_Prod.ToString());
decimal CalcPremium = 0, CalcProd = 0;
if (Type == "A - AREA" || Type == "M - ADMISSION" || Type == "U - UNITS" || Type == "O - OTHER")
{
CalcPremium = (Premium * nautilusPremiumBasis);
lblNautilusPremisesOp.Text = getCurrencyFormat(Math.Round(CalcPremium).ToString());
CalcProd = (Prod * nautilusPremiumBasis);
lblNautilusProductsCoop.Text = getCurrencyFormat(Math.Round(CalcProd).ToString());
}
if (Type == "C - TOTAL COST" || Type == "P - PAYROLL" || Type == "S - GROSS SALES")
{
CalcPremium = (Premium * nautilusPremiumBasis) / 1000;
lblNautilusPremisesOp.Text = getCurrencyFormat(Math.Round(CalcPremium).ToString());
CalcProd = (Prod * nautilusPremiumBasis) / 1000;
lblNautilusProductsCoop.Text =getCurrencyFormat(Math.Round(CalcProd).ToString());
}
lblNautilusGLPremium.Text = getCurrencyFormat(Math.Round((Math.Round(CalcProd) + Math.Round(CalcPremium))).ToString());
lblNautilusSubTotal.Text = getCurrencyFormat(Math.Round((Math.Round(CalcProd) + Math.Round(CalcPremium))).ToString());
lblNautilusGrandTotal.Text = getCurrencyFormat(Math.Round((Math.Round(CalcProd) + Math.Round(CalcPremium))).ToString());
//string jstablelattest = "moneyCoverage";
//ClientScript.RegisterClientScriptResource(this.GetType(), jstablelattest);
}