When clicking on the submit button when adding a new service, if errors exist, the focus of the page goes to the top of the screen when the submit button is clicked. The focus should stay in the service details panel so that the user can see the error messages.

put your code in try catch block
void button_click(object sender,EventArgs e)
{
try
{
your code goes here
}
catch
{
myErrorPanel.focus();
}
}

i am sorry i think i mislead you, you want the panel to scroll into view , here you go :

if your button is a postback control , your code is here :
again in the catch block add this :

page.RegisterStartupScript("key2", "<script> document.getElementById('" + controlToScroll.ClientID + "').scrollIntoView();</script>");

if your button is an asynchronous postback button then add this script to the same where

ScriptManager.RegisterStartupScript(Page, typeof(Page), "key2", "document.getElementById('" + controlToScroll.ClientID + "').scrollIntoView();", true);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.