Translate

Home > August 2012

August 2012

ASP.NET Javascript combobox value checking

Monday, August 27, 2012 Category : 0

 var shopNmae = document.getElementById('<%=ddlShopName.ClientID %>');
           
            if(shopNmae.options[shopNmae.selectedIndex].text == 'Select')
            {
               alert('Select Shop Name');
               return;
            }

JavaScript from C#

Sunday, August 26, 2012 Category : , 0

Call Javascript from c# code.

here PrintTree() is a  javascript method.


For Post Back Button Event :

ScriptManager.RegisterStartupScript(btnViewGraph, btnViewGraph.GetType(), "addScript", "PrintTree();", true);



For Async Post Back Button Event


public void showReportAjax(string pageUrl, string param, Type cType, Page oPage, Control ctrl)
{
ScriptManager.RegisterStartupScript(ctrl, typeof(string), "redirect", "window.open('" + pageUrl + param + "');", true);
}


public static void ShowMessage(string msg)
{
Page page = HttpContext.Current.Handler as Page;
msg = msg.Replace("\r\n", "
");
msg = msg.Replace("'", "");
ScriptManager.RegisterStartupScript(page, page.GetType(), "msgs", "ShowMessage('" + msg + "');", true);
}

Powered by Blogger.