protected string to public static string
-
How can i use the protected string (TextBox.Text) inside the public static function? I get the following error on the return statement: MyWebForm.test.tb1' denotes a 'field' where a 'class' was expected
public class test : System.Web.UI.Page { protected System.Web.UI.WebControls.TextBox tb1; private void Page_Load(object sender, System.EventArgs e) { } public static string GetDate() { **return tb1;** }
-
How can i use the protected string (TextBox.Text) inside the public static function? I get the following error on the return statement: MyWebForm.test.tb1' denotes a 'field' where a 'class' was expected
public class test : System.Web.UI.Page { protected System.Web.UI.WebControls.TextBox tb1; private void Page_Load(object sender, System.EventArgs e) { } public static string GetDate() { **return tb1;** }
u cant use a non static member inside a static function.... and if u try to convert the textbox obj into a static one they've used a this pointer to tht so throwing a error... try this code.. public class WebForm1 : System.Web.UI.Page { protected System.Web.UI.WebControls.TextBox tb; protected System.Web.UI.WebControls.Button Button1; protected System.Web.UI.WebControls.Label l1; protected static string s; private void Page_Load(object sender, System.EventArgs e) { getvalue(); l1.Text = WebForm1.gd(); } public string getvalue() { s = tb.Text; return s; } public static string gd() { return s; } } sathy