托管错误/编译错误 [英] Hosting error/Compilation Error

查看:114
本文介绍了托管错误/编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我的代码工作正常但是当我上传到托管服务器时我收到以下错误:



编译错误:

编译器错误消息:CS1526:新表达式需要()或[]后类型



来源错误:





第29行:b.Text = dv [0] .ToString();

第30行:Panel1.Controls.Add(b);

第31行:Panel1.Controls.Add(新标签{Text =});

第32行:b.CheckedChanged + = new EventHandler(b_CheckedChanged);

第33行:}



源文件:d:\hosting \ 11070957\html\Medical_Application.aspx.cs行:31



i认为错误在第31行。请帮我解决这个问题

Hi All,

My code was working properly however when i uploaded on hosting server i got the below error:

Compilation Error:
Compiler Error Message: CS1526: A new expression requires () or [] after type

Source Error:


Line 29: b.Text = dv[0].ToString();
Line 30: Panel1.Controls.Add(b);
Line 31: Panel1.Controls.Add(new Label { Text = "" });
Line 32: b.CheckedChanged += new EventHandler(b_CheckedChanged);
Line 33: }

Source File: d:\hosting\11070957\html\Medical_Application.aspx.cs Line: 31

i think error is on line 31. please help me in resolving this issue

推荐答案

>我认为错误在第31行。



我也这么认为。尝试:



> i think error is on line 31.

I think so too. Try:

Panel1.Controls.Add(new Label() { Text = "" });

Label lbl = new Label();
lbl.Text = "some text";

Panel1.Controls.Add(lbl);





或者你也可以试试这个,但你会必须创建标签实例。



or you can try this also ,but you will have to create an instance of label.


这篇关于托管错误/编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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