I am trying this code and I got an error say System.NullReferenceException: Object reference not set to an instance of an object. when I run the website even though this code worked well in the tutorial.
private SearchInput GetSearchInput()
{
return new SearchInput()
{
id = txt_id.Text,
email = txt_email.Text,
gender = ddl_gender.SelectedItem.Text,
fname = txt_fname.Text,
lname = txt_lname.Text
};
}
I am coding on ASP.NET and C#. Please help.
I tried to put a variable
private SearchInput GetSearchInput()
{
SearchInput newinput = new SearchInput()
{
id = txt_id.Text,
email = txt_email.Text,
gender = ddl_gender.SelectedItem.Text,
fname = txt_fname.Text,
lname = txt_lname.Text
};
return newinput;
}
but it still did not work.