Reputation: 753
I have a textbox that will collect the ip address from the user. I double click in the designer to take me to my .CS code it takes me to the correct location for _TextChanged.
One thing I notice it that event is grayed out and say it's not used, even though I click on it and allowed me to enter code. I tryed moving it outside of the partial class, it just made all the controls unseeable. I have no errors at design time.
Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1061: 'ASP.memberpages_ftpform1_aspx' does not contain a definition for 'txtServerIP_TextChanged' and no extension method 'txtServerIP_TextChanged' accepting a first argument of type 'ASP.memberpages_ftpform1_aspx' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 7: Line 8: FTP Server: Line 9: 0.0.0.0 Line 10: Line 11: User Name:
Upvotes: 1
Views: 24747
Reputation: 1
It is because the event definition for the control is missing hence it is giving an error
As shown below I was getting above error datalist control saying definition for DataList1_SelectedIndexChanged definition was missing.
To resolve this issue. double click on the control and see if you are getting definition for the event it is showing in the error.
some times Visual studio behaves special and when you click on the control it will not take you to code behind window Hence save all the work in the project and close. re-open the project and repeate the step to get into code behind window to look the event definition.
still if you are not able to see the definition for event, just put another control(datalist) on the form and double click to go to window. it will take you the codebehind and to the event definition. then you can remove the additional control added on the form. Now double click on the previous datalist control which was giving error and you can see the definition for the event. the above steps will resolve this issue.
repeat the steps for any other controls
Upvotes: 0
Reputation: 31
Just click on the textbox in .aspx page and then right click on textbox and select properties, then select Event (icon) in properties window, then remove the text in front of TextChanged (Event) now compile the page.
Upvotes: 3
Reputation: 3536
Make sure your text box has an ontextchanged property with the method name from your code behind.
<asp:TextBox ID="TextBox1" runat="server" ontextchanged="TextBox1_TextChanged"></asp:TextBox>
Inside your webform partial class:
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
}
Upvotes: 4