ASP.NET - Image Button problem
Asked By Sudhansu shekhar on 13-Feb-12 02:18 AM
Hi all,
I'm getting struck, when i want to put Image Button control instead of normal button. In click event i have also changed ImageClickEventArgs. Inside click button, I'm using If condition, and code is:
if (btnSave.Text == "Save")
{ string testStr="SELECT ClsSubId FROM Tbl_ExamSchedule" +
" WHERE (SchClassId = '" + ddlClass.Text + "') AND (ClsExmId = '" + ddlExam.Text + "') AND (SchAcadId = '" + acadID .ToString ()+ "') AND (ClsSubId = '"+ddlSub.Text +"')";
SqlDataReader dr = obj.ExecuteReader(testStr);
Now I'm getting following error on highlighted text:
CS0122: 'System.Web.UI.WebControls.ImageButton.Text' is inaccessible due to its protection level
Pls help me out.......Thanks in advance.
Web Star replied to Sudhansu shekhar on 13-Feb-12 02:29 AM
you need to check the protection level of that image control when it should be protected or public, it cannot be private. In your code that set with private that's why your are getting such inaccessible due to its protection level error to change it to protected or public.
Hope that helps your
kalpana aparnathi replied to Sudhansu shekhar on 13-Feb-12 04:07 AM
hi,
Either:
Remove OnClick="Button1_Click" from the html part
--or--
Remove the event subscription: this.Button1.Click += new System.EventHandler(this.Button1_Click);
*and* set the accessible level to protected (recommended), public or internal for the method Button1_Click.
One thing that imagebutton not have text property so use commandName as a property for validation so check it also.
Regards,