If you’re having trouble setting the default button in an ASP.NET Panel that has a Master Page…

Posted: August 28, 2011 in Uncategorized

I struggled with this for about a day, and there were a lot of sites saying I should just use button.ID or button.UniqueID to set the default button for a panel. Nope, that wasn’t working. Some users were complaining the issue was only occurring on setting default button when in a control contained in a Master page.

The error would be:

The DefaultButton of panel  or page must be the ID of a control of type IButtonControl.

So, here’s what you do to fix it:


// Set the default buttons.

((Panel)Page.FindControl(nameofthepanel.UniqueID)).DefaultButton = nameofthebutton.ID;


I hope that helps Smile

Best,

-Auri

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s