J
jhcorey
I've typically been working with VB.Net. When I want to create code
that runs when a button is clicked, I'll go to the code-behind, find
the button in the dropdown in the top left, then select the click event
in the dropdown in the top right. The ide then creates an empty
function and I type in my code.
Now I'm working with C#. I found that I could create the skeleton of
the function by clicking on the button in the design view of the page.
But now it seems it's messing things up.
For one thing, sometimes InitializeComponent gets cleared out.
Otherwise, I have some buttons working, but right now I'm trying to put
a button on a user control and load the control into a placeholder.
Here is code from the user control:
protected System.Web.UI.WebControls.Button btnRetrieve;
.....
private void InitializeComponent()
{
this.btnRetrieve.Click += new
System.EventHandler(this.btnRetrieve_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
private void btnRetrieve_Click(object sender, System.EventArgs e)
{
}
When I try to run this, I get "Object reference not set to an instance
of an object" in the first line in InitializeComponent.
Any explanation would be appreciated.
TIA,
Jim
that runs when a button is clicked, I'll go to the code-behind, find
the button in the dropdown in the top left, then select the click event
in the dropdown in the top right. The ide then creates an empty
function and I type in my code.
Now I'm working with C#. I found that I could create the skeleton of
the function by clicking on the button in the design view of the page.
But now it seems it's messing things up.
For one thing, sometimes InitializeComponent gets cleared out.
Otherwise, I have some buttons working, but right now I'm trying to put
a button on a user control and load the control into a placeholder.
Here is code from the user control:
protected System.Web.UI.WebControls.Button btnRetrieve;
.....
private void InitializeComponent()
{
this.btnRetrieve.Click += new
System.EventHandler(this.btnRetrieve_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
private void btnRetrieve_Click(object sender, System.EventArgs e)
{
}
When I try to run this, I get "Object reference not set to an instance
of an object" in the first line in InitializeComponent.
Any explanation would be appreciated.
TIA,
Jim