/// Form 의 TextBox 에서 Enter키를 치면 PostBack 되는 것을 막고 버튼에 Progress Bar JavaScript Event 를 연결
/// </summary>
public void PreventSubmitOnEnter()
{
string strFormName;
HttpContext hc = HttpContext.Current;
hc.Response.Write("<div id='divProgress' style='DISPLAY: none; LEFT: 30%; POSITION: absolute; TOP: 15%'><IMG id='img' src='../images/loadingbar.gif'></div>");
if (!IsPostBack)
{
foreach (System.Web.UI.Control formCont in this.Controls)
{
if (formCont is System.Web.UI.HtmlControls.HtmlForm)
{
strFormName = formCont.ClientID;
foreach(System.Web.UI.Control cont in formCont.Controls)
{
// TextBox 에는 Enter 키 이벤트 막기
if ( cont is System.Web.UI.WebControls.TextBox )
{
TextBox tbox = cont as TextBox;
tbox.Attributes.Add("onkeypress","if(event.keyCode==13){return false;}");
}
// Button 에는 ProgressBar 이벤트 연결
else if ( cont is System.Web.UI.WebControls.Button)
{
Button btn = cont as Button;
string strHandler = "javascript:document."+strFormName+".style.display = 'none' ; document.all.img.src='../images/loadingbar.gif' ; document.all.divProgress.style.display='';";
btn.Attributes.Add("onclick", strHandler);
}
}
}
} // foreach (System.Web.UI.Control formCont in this.Controls)
} // if ( !PostBack)
} // 메소드