Sunday, 19 January 2014

IsCrossPagePostBack and find previous pages usercontrol value to another page

 if (Page.PreviousPage != null && Page.PreviousPage.IsCrossPagePostBack)
            {
                ContentPlaceHolder cph = (ContentPlaceHolder)Page.PreviousPage.Master.FindControl("MainContent");
                if (cph != null)
                {
                    UserControl ucViewLocateUs = (UserControl)cph.FindControl("ViewLocateUs1");
                    if (ucViewLocateUs != null)
                    {
                        DropDownList dpdListCity = ucViewLocateUs.FindControl("dpdListCity") as DropDownList;
                        FillAllLocateUsDetails(dpdListCity);
                    }
                }
            } 

Wednesday, 15 January 2014

Default button click on enter use javascript

<script type="text/javascript">
    if (document.addEventListener) {//if Firefox
        document.addEventListener("keypress", fireFoxHandler, true);
       
    } else {
       
        document.attachEvent("onkeyup", ieHandler);
    }
   
    function fireFoxHandler(evt) {
        if (evt.keyCode == 13) {
            document.getElementById("btnSave").click();
           
        }
    }

    function ieHandler(evt) {
        if (evt.keyCode == 13) {
            document.getElementById("btnSave").click();
        }
    }

</script>

<asp:Button ID="btnSave" ValidationGroup="Submit" runat="server" Text="Save" OnClick="btnSave_Click"
                    CssClass="save_btn" ClientIDMode="Static" />

Monday, 23 December 2013

Add Remove Header Tag inside Tag Meta,Title,Canonical,link etc

 this.Page.Header.Title = "page title";
               
                    HtmlLink link = (HtmlLink)Page.Header.FindControl("idcanonical");
                    Page.Header.Controls.Remove(link);
                
                   HtmlLink link1 = new HtmlLink();
                    link1.Href = "http://www.test.com/equity-funds";
                    link1.Attributes["rel"] = "canonical";
                    this.Page.Header.Controls.Add(link1);

                    HtmlMeta metadesc = (HtmlMeta)Page.Header.FindControl("meta_funds");
                    Page.Header.Controls.Remove(metadesc);

                    HtmlMeta metakey = (HtmlMeta)Page.Header.FindControl("keywords_funds");
                    Page.Header.Controls.Remove(metakey);

                    HtmlMeta metadesc1 = new HtmlMeta();
                    metadesc1.Name = "Description";
                    metadesc1.Content = "test.";
                    this.Page.Header.Controls.Add(metadesc1);

Thursday, 12 December 2013

MVC paging

http://www.codeproject.com/Articles/28605/Pagination-Class-for-ASP-NET-MVC

Wednesday, 4 December 2013

Google plus api intigration

 https://developers.google.com/+/web/+1button/
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
      <script type="text/javascript" src="https://apis.google.com/js/platform.js"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
 <a href='javascript:;' title="Google+" target="_blank" class="g-plusone" data-size="small" data-href="http://www.pramod.com">
                      
                        </a>
    </div>
    </form>
</body>
</html>

Tuesday, 29 October 2013

Jquery bind server side in cs pages

 System.Text.StringBuilder strScriptFB = new System.Text.StringBuilder();
        strScriptFB.Append("<script type=\"text/javascript\">");
        strScriptFB.Append("$(document).ready(function () {");
        strScriptFB.Append("jQuery.getScript('http://connect.facebook.net/en_US/all.js', function () { });");

        strScriptFB.Append("$('#divFBLike').append('<div id=\"fb-root\"></div>');");
        strScriptFB.Append("$('#divFBLike').append('<div class=\"fb-like\" data-href=\"" + strFacebookHTTP + "/idfc-tv-playing.aspx?Vid=" + SessionManager.intVideosID.ToString() + "&fbvidID1234=" + SessionManager.intVideosID.ToString() + "&isValid=1\"data-send=\"false\" data-width=\"210\" height=\"300\" data-show-faces=\"false\"></div><p>&nbsp;</p>');");
        strScriptFB.Append("$('#facebookHolder').append('<fb:comments href=\"" + strFacebookHTTP + "/idfc-tv-playing.aspx?Vid=" + SessionManager.intVideosID + "&fbvID23=" + SessionManager.intVideosID.ToString() + "&isValid=1\" num_posts=\"2\" width=\"213\"></fb:comments>'); ");
        strScriptFB.Append("}); </script>");

        ScriptManager.RegisterClientScriptBlock(this.Page, GetType(), "alert1", strScriptFB.ToString(), false);

Wednesday, 16 October 2013

Bind Dropdown use xml, Dropdown fill by xml

  DataSet  ds= new DataSet();
        ds.ReadXml(Server.MapPath("BindXMLToDropDown.xml"));

        DropDownList1.DataSource = ds;
        DropDownList1.DataTextField = "category";
        DropDownList1.DataValueField = "lastUpdated";
        DropDownList1.DataBind();