Click here to Skip to main content
15,867,906 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
[no name] 26-Jun-13 10:02am    
Panel1.Controls.Add(new Label() { Text = "" });
Johnny J. 26-Jun-13 11:22am    
I don't understand why you continue to do that; Supply a solution as a comment. Why do you continually fail to see that that makes it impossible for the OP to mark his question as solved???

> i think error is on line 31.

I think so too. Try:

C#
Panel1.Controls.Add(new Label() { Text = "" });
 
Share this answer
 
v2
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900