English 中文(简体)
显示长期格式错误的案文箱
原标题:textbox string to long format error

i 正在利用2005年和2008年的服务器开展一个项目。

我把一个文本箱的案文放在了很长的变数(电话号码),因为背后将电话号码放在大话中。

long phone = long.Parse(TextBox4.Text);

这部法律在加入我的电话号码时做了罚款,但如果一个人不知道或不想插入,则可以选择电话号码无效。

如果说听话,那么提交书子就不必进入电话号码,那就错了!

Server Error in  /  Application.

Input string was not in a correct format.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:    

Line 48:     string deptName = TextBox2.Text;
Line 49:     string deptLoc = TextBox3.Text;
Line 50:     long phone = long.Parse(TextBox4.Text);
Line 51:     string flag = "";

请更正我的错误,我不理解用什么其他方法 par!

最佳回答

。 或输入错误,TryParse():

long l;
if (long.TryParse(textBox.Text, out l))
{
    // success
}
else
{
    // not. probably throw an exception yourself. or just ignore
}
问题回答

电话号码应当允许括号、空间、邮单、+符号、符号和当然的电话号码从0(这样,0-1234 567891就变成123456891)。

页: 1 很少的电话号码可以长期储存或储存。

希望会有所帮助。

Try the Boolean long. TryParse (string, byref long) methods. 如果教区失败的话,那就没有例外,而是回到了ean。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签