尝试打印不同报告时出错 [英] Getting Error when trying to print different reports

查看:73
本文介绍了尝试打印不同报告时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网页表单,上面有一个打印按钮。打印按钮根据三个文本框的值打印出四种不同的报告。



这是打印按钮代码:

  if (Page.IsValid)
{
int iTextBoxFTE40 = Convert.ToInt32(TextBoxFTE40.Text);
int iTextBoxHC50 = Convert.ToInt32(TextBoxHC50.Text);
int iTextBoxFTE4050 = Convert.ToInt32(TextBoxFTE4050);

if (iTextBoxFTE40 > 40
{
TextBoxINST_ID.Text =会话[ inst_id< /跨度>]的ToString();
ClientScript.RegisterStartupScript( this .GetType(), onclick < script language = javascript> window.open('ReportFormFTE40.aspx , 'PrintMe', '身高= 650像素,宽= 950像素,滚动条= 1');< /脚本>中);
ScriptManager.RegisterStartupScript( this typeof (页面), myscript alert('您已成功提交了General和Enrollment Profile的电子部分。请将您签名的Profile以及任何所需的附件发送到SACSCOC,Attn:Profiles,1866 Southern Lane,Decatur,Ga 30033。'); location.href = 'WelcomeMenu.aspx'; true );
}
其他 if (iTextBoxHC50 > 50
{
TextBoxINST_ID.Text = Session [ inst_id]。ToString();
ClientScript.RegisterStartupScript( this .GetType(), onclick < script language = javascript> window.open('ReportFormFTE50.aspx , 'PrintMe', '身高= 650像素,宽= 950像素,滚动条= 1');< /脚本>中);
ScriptManager.RegisterStartupScript( this typeof (页面), myscript alert('您已成功提交了General和Enrollment Profile的电子部分。请将您签名的Profile以及任何所需的附件发送到SACSCOC,Attn:Profiles,1866 Southern Lane,Decatur,Ga 30033。'); location.href = 'WelcomeMenu.aspx'; true );
}
else if (iTextBoxFTE4050 > 90
{
TextBoxINST_ID.Text = Session [ inst_id]。ToString();
ClientScript.RegisterStartupScript( this .GetType(), onclick < script language = javascript> window.open('ReportFormFTE4050.aspx , 'PrintMe', '身高= 650像素,宽= 950像素,滚动条= 1');< /脚本>中);
ScriptManager.RegisterStartupScript( this typeof (页面), myscript alert('您已成功提交了General和Enrollment Profile的电子部分。请将您签名的Profile以及任何所需的附件发送到SACSCOC,Attn:Profiles,1866 Southern Lane,Decatur,Ga 30033。'); location.href = 'WelcomeMenu.aspx'; true );
}
else
{
TextBoxINST_ID.Text = Session [ inst_id]。ToString();
ClientScript.RegisterStartupScript( this .GetType(), onclick < script language = javascript> window.open('ReportFormFTE.aspx , 'PrintMe', '身高= 650像素,宽= 950像素,滚动条= 1');< /脚本>中);
ScriptManager.RegisterStartupScript( this typeof (页面), myscript alert('您已成功提交了General和Enrollment Profile的电子部分。请将您签名的Profile以及任何所需的附件发送到SACSCOC,Attn:Profiles,1866 Southern Lane,Decatur,Ga 30033。'); location.href = 'WelcomeMenu.aspx'; true );
}





单击打印按钮时出现此错误:

无法将'System.Web.UI.WebControls.TextBox'类型的对象强制转换为'System.IConvertible'。



什么这是否意味着?它发生在这一行:

  int  iTextBoxFTE4050 = Convert.ToInt32(TextBoxFTE4050); 





如何解决这个问题?

解决方案

如果你不愿意阅读< a href =http://www.codeproject.com/Answers/837831/Print-different-reports-depending-on-Value-in-text> Chill60的回答 [ ^ ] to 您之前的这个问题的副本 [ ^ ],你会知道答案:

  int  iTextBoxFTE4050 = Convert.ToInt32(TextBoxFTE4050.Text); 


I have a web form that has a print button on it. The print button prints out four different reports depending on the value of the three textboxes.

Here is the Print button code:

if (Page.IsValid)
               {
                   int iTextBoxFTE40 = Convert.ToInt32(TextBoxFTE40.Text);
                   int iTextBoxHC50 = Convert.ToInt32(TextBoxHC50.Text);
                   int iTextBoxFTE4050 = Convert.ToInt32(TextBoxFTE4050);

                   if (iTextBoxFTE40 > 40)
                   {
                       TextBoxINST_ID.Text = Session["inst_id"].ToString();
                       ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language=javascript>window.open('ReportFormFTE40.aspx','PrintMe','height=650px,width=950px,scrollbars=1');</script>");
                       ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You have successfully submitted the electronic portion of the General and Enrollment Profile.  Please send your signed Profile along with any required attachments to SACSCOC, Attn: Profiles, 1866 Southern Lane, Decatur, Ga 30033.');location.href='WelcomeMenu.aspx';", true);
                   }
                   else if (iTextBoxHC50 > 50)
                   {
                       TextBoxINST_ID.Text = Session["inst_id"].ToString();
                       ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language=javascript>window.open('ReportFormFTE50.aspx','PrintMe','height=650px,width=950px,scrollbars=1');</script>");
                       ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You have successfully submitted the electronic portion of the General and Enrollment Profile.  Please send your signed Profile along with any required attachments to SACSCOC, Attn: Profiles, 1866 Southern Lane, Decatur, Ga 30033.');location.href='WelcomeMenu.aspx';", true);
                   }
                   else if (iTextBoxFTE4050 > 90)
                   {
                       TextBoxINST_ID.Text = Session["inst_id"].ToString();
                       ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language=javascript>window.open('ReportFormFTE4050.aspx','PrintMe','height=650px,width=950px,scrollbars=1');</script>");
                       ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You have successfully submitted the electronic portion of the General and Enrollment Profile.  Please send your signed Profile along with any required attachments to SACSCOC, Attn: Profiles, 1866 Southern Lane, Decatur, Ga 30033.');location.href='WelcomeMenu.aspx';", true);
                   }
                   else
                   {
                       TextBoxINST_ID.Text = Session["inst_id"].ToString();
                       ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language=javascript>window.open('ReportFormFTE.aspx','PrintMe','height=650px,width=950px,scrollbars=1');</script>");
                       ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You have successfully submitted the electronic portion of the General and Enrollment Profile.  Please send your signed Profile along with any required attachments to SACSCOC, Attn: Profiles, 1866 Southern Lane, Decatur, Ga 30033.');location.href='WelcomeMenu.aspx';", true);
                   }



When the Print button is clicked this error comes up:

Unable to cast object of type 'System.Web.UI.WebControls.TextBox' to type 'System.IConvertible'.


What does this mean? It happens on this line:

int iTextBoxFTE4050 = Convert.ToInt32(TextBoxFTE4050);



How can I fix this?

解决方案

If you'd bothered to read Chill60's answer[^] to your previous copy of this question[^], you'd know the answer:

int iTextBoxFTE4050 = Convert.ToInt32(TextBoxFTE4050.Text);


这篇关于尝试打印不同报告时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆