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();

Friday, 11 October 2013

Save live image in c sharp

    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
 -----------------------------------------
 protected void Button1_Click(object sender, EventArgs e)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(TextBox1.Text.Trim());
        string filname = TextBox1.Text.Trim();
        filname = string.Format("{0:MMMMyyyyHHmmssFFFF}", DateTime.Now) + filname.Substring(filname.LastIndexOf("/") + 1);

        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        if ((response.StatusCode == HttpStatusCode.OK ||
                   response.StatusCode == HttpStatusCode.Moved ||
                   response.StatusCode == HttpStatusCode.Redirect) &&
                   response.ContentType.StartsWith("image", StringComparison.OrdinalIgnoreCase))
        {
            using (Stream inputStream = response.GetResponseStream())
            using (Stream outputStream = File.Create(Server.MapPath("images") + "\\" + filname + ""))
            {
                byte[] buffer = new byte[4096];
                int bytesRead;
                do
                {
                    bytesRead = inputStream.Read(buffer, 0, buffer.Length);
                    outputStream.Write(buffer, 0, bytesRead);
                } while (bytesRead != 0);
            }
        }
    }

Sum one by one ,Second highest salary

select a.Id, a.Name, sum(b.Name) as sum from Table_5 a cross join Table_5 b where b.Id <= a.Id group by a.Id, a.Name



Select * From Table_5 T1 Where 3=(Select Count(Distinct(t2.salary)) From Table_5 T2 Where T2.salary > T1.salary)



select min(name) from Table_5 where name in (select   distinct top 5 name  from Table_5 order by name desc)

Wednesday, 9 October 2013

404 error file not found and directory HttpError throw handle

  <httpErrors existingResponse="Replace" errorMode="Custom">

      <remove statusCode="404" subStatusCode="-1" />
      <!--<error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="/errorp.aspx" responseMode="Redirect" />-->
      <error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="/errorpage.aspx" responseMode="ExecuteURL" />
      <error statusCode="400" path="/" responseMode="ExecuteURL" />

    </httpErrors>

  </system.webServer>

Thursday, 26 September 2013

How Auto poastbak in ie 10 Enternet exploer 10 in .net

private void Page_Init(object sender, EventArgs e)
    {
        Page.ClientTarget = "uplevel";
    }

Wednesday, 25 September 2013

Url Rewite

protected void Application_BeginRequest(Object sender, EventArgs e)
    {

 if (HttpContext.Current.Request.QueryString["isValid"] == null)
                {
                    if (HttpContext.Current.Request.UrlReferrer == null && HttpContext.Current.Request.QueryString.Count > 0 && !(HttpContext.Current.Request.Url.ToString().ToLower().Contains("fundpage.aspx")))
                    {
                        if (!HttpContext.Current.Request.Url.ToString().Contains("?2") && !HttpContext.Current.Request.Url.ToString().ToLower().Contains("?formcentre"))
                        {
                            Response.Redirect("~/errorpage.aspx");
                        }

                    }
                    else
                    {
                        // BusinessLogic.URLRewriter.ProcessRequest();
                        URLRewriterNew.URLRewriterNew.ProcessRequest();
                        URLTagRewriter.ProcessRequest();
                    }
                }
                else if (HttpContext.Current.Request.UrlReferrer == null)
                {
                    //Response.Redirect("~/default.aspx");
                }
}


=========================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Web;
using System.Data.SqlClient;
using System.Data;

using System.Xml;

public class URLTagRewriter : IConfigurationSectionHandler
{

    #region Private Variables
    // static AccessData _accessData = new AccessData();
    #endregion
    public static void ProcessRequest()
    {

        //string zSubst = oRewriter.GetSubstitution(HttpContext.Current.Request.Path);

        //Added by Deepak T to check the keyword

        if (HttpContext.Current.Request.Path.ToLower().Contains("aspx"))
        {
            //do nothing
            string zSubst = string.Empty;
            if (HttpContext.Current.Request.Url.AbsoluteUri.ToString().ToLower().Contains("?ptagid="))
            {
                string strPid = HttpContext.Current.Request.QueryString["ptagid"].ToString();
                int id = int.Parse(strPid);
                zSubst = ReadURLFromSql(id.ToString());
                if (zSubst.Length > 0)
                {
                    if (HttpContext.Current.Request.RequestType != "POST")
                    {
                        HttpContext.Current.Response.Redirect(zSubst);
                        //HttpContext.Current.RewritePath(zSubst);
                    }
                }

            }
            else
            {
                //HttpContext.Current.Response.Redirect("~/default.aspx");
            }

        }
        else if (HttpContext.Current.Request.Path.ToLower().Contains("."))
        {
            //do nothing
        }
        else
        {
            string zSubst = string.Empty;
            string strPid ="";
            zSubst = ReadURLFromSql();//ReadXML(HttpContext.Current.Server.MapPath("~/URL.xml"));

            if (zSubst.Length > 0)
            {
                HttpContext.Current.RewritePath(zSubst);
            }
            else
            {
                //HttpContext.Current.Response.Redirect("~/default.aspx");
                // throw new Exception("Page not found");
            }
        }
    }

    public static string ReadURLFromSql()
    {
        string strRequestPath = string.Empty;
        string dbPath = string.Empty;
        string strMatchPath = string.Empty;
        strRequestPath = HttpContext.Current.Request.Path; // got the requested path
        strMatchPath = strRequestPath.Substring(strRequestPath.LastIndexOf("/"), strRequestPath.Length - (strRequestPath.LastIndexOf("/")));
        if (strMatchPath.Contains("/"))
        {
            strMatchPath = strMatchPath.Remove(strMatchPath.IndexOf("/"), 1);
        }

        if (strMatchPath.Contains("'"))
        {
            int index = strMatchPath.IndexOf("'");
            index = index + 1;
            strMatchPath = strMatchPath.Insert(index, "'");
        }
        else
        {
            // strMatchPath = "7";
        }


        DataSet dsURL = new DataSet();


        //dsURL = GetFundPageLink("GetFundPageIDByLink","", strMatchPath);




        //if (dsURL != null && dsURL.Tables.Count > 0 && dsURL.Tables[0].Rows.Count > 0)
        //{
        //    dbPath = dsURL.Tables[0].Rows[0]["ID"].ToString();
      //  string strPid = HttpContext.Current.Request.QueryString["tagid"].ToString();
       //}
        //else
        //{
        //    dbPath = "";
        //}
  
        if (strMatchPath == "equity-funds")
        {
            dbPath = "1";
        }
        else if (strMatchPath == "debt-funds")
        {
            dbPath = "2";
        }
        else if (strMatchPath == "hybrid-funds")
        {
            dbPath = "3";
        }
        else if (strMatchPath == "tax-saving-funds")
        {
            dbPath = "7";
        }
        else if (strMatchPath == "long-term-funds")
        {
            dbPath = "18";
        } else
        {
            dbPath = "";
        }

        string str = string.Empty;
        if (dbPath != "")
            str = "~/mutual-funds-at-a-glance.aspx?tagID=" + dbPath + "";
        else
            str = "";

        return str;
    }

    public static string ReadURLFromSql(string fundID)
    {
        string strRequestPath = string.Empty;
        string dbPath = string.Empty;
        string strMatchPath = string.Empty;
        strRequestPath = HttpContext.Current.Request.Path; // got the requested path


        DataSet dsURL = new DataSet();

        //dsURL = GetFundPageLink("GetFundPageLink", fundID,"");

        if (fundID == "1")
        {
            dbPath = "equity-funds";
        }
        else if (fundID == "2")
        {
            dbPath = "debt-funds";
        }
        else if (fundID == "3")
        {
            dbPath = "hybrid-funds";
        }
        else if (fundID == "7")
        {
            dbPath = "tax-saving-funds";
        }
         else if (fundID == "18")
        {
            dbPath = "long-term-funds";
        }


        //if (dsURL!=null && dsURL.Tables.Count>0 &&  dsURL.Tables[0].Rows.Count > 0)
        //{
        //dbPath = "pramod";// dsURL.Tables[0].Rows[0]["FundPageLink"].ToString();
        // }

        string str = string.Empty;
        if (dbPath != "")
            str = "~/" + dbPath;
        else
            str = "";

        return str;
    }


    //public static DataSet GetFundPageLink(string strAction, string strFundID,string strFundLink)
    //{
    //    try
    //    {

    //        _accessData.Section = "FundPageLinks";
    //        object[] obj = _accessData.GetObject();
    //        obj[0] = strAction;
    //        obj[1] = strFundID;
    //        obj[2] = strFundLink;

    //        DataSet _ds = _accessData.getDataSet(obj);
    //        return _ds;
    //    }
    //    catch (Exception ex)
    //    {
    //        throw (ex);
    //    }
    //}



    #region Implementation of IConfigurationSectionHandler
    public object Create(object parent, object configContext, XmlNode section)
    {
        //_oRules = section;

        // TODO: Compile all Regular Expressions

        return this;
    }

    #endregion

}

Monday, 16 September 2013

More pageing in .net use ListView with DataPager

 =============================ASPX page==================================
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="listview_paging.aspx.cs"
    Inherits="listview_paging" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div class="StatusMessage">
        <asp:ListView ID="lvEmployee" runat="server" OnDataBound="lvEmployee_DataBound">
            <LayoutTemplate>
                <table id="itemPlaceholderContainer">
                    <tr runat="server" id="itemPlaceholder">
                    </tr>
                </table>
            </LayoutTemplate>
            <ItemTemplate>
                <tr>
                    <td>
                        Address:<asp:Label ID="AddressLabel" runat="server" Text='<%# Eval("Id") %>' />
                    </td>
                </tr>
            </ItemTemplate>
        </asp:ListView>
        <div id="divpaging" runat="server">
            <asp:DataPager ID="DataPager1" runat="server" PagedControlID="lvEmployee" PageSize="2"
                OnPreRender="DataPager1_PreRender">
                <Fields>
                   <%-- <asp:NumericPagerField ButtonCount="5" />--%>
                    <asp:NextPreviousPagerField ShowFirstPageButton="true" ShowLastPageButton="true"
                        ShowNextPageButton="true" ShowPreviousPageButton="true" />
                    <asp:TemplatePagerField OnPagerCommand="listPages_Click">
                        <PagerTemplate>
                            <asp:Button ID="listPages" runat="server" Text="more"></asp:Button>
                        </PagerTemplate>
                    </asp:TemplatePagerField>
                </Fields>
            </asp:DataPager>
        </div>
    </div>
    </form>
</body>
</html>

===============================cs pages===================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class listview_paging : System.Web.UI.Page
{

        int CurrentPage = 2;

        public int PageNumber
        {
            get
            {
                if (ViewState["PageNumber"] != null)
                    return Convert.ToInt32(ViewState["PageNumber"]);
                else
                    return 0;
            }
            set
            {
                ViewState["PageNumber"] = value;

            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                PageNumber = 1;
                ProductList db = new ProductList();
                lvEmployee.DataSource = db.GellAll();
                lvEmployee.DataBind();

            }

        }



        protected void lvEmployee_DataBound(object sender, EventArgs e)
        {


            //DropDownList ddl = DataPager1.Controls[1].FindControl("ddlPage") as DropDownList;

            int PageCount = (DataPager1.TotalRowCount / 2);

            if (PageCount * 2 != DataPager1.TotalRowCount)
            {

                PageCount = PageCount + 1;

            }

            //for (int i = 0; i < PageCount; i++)
            //{

            //    ddl.Items.Add(new ListItem((i + 1).ToString(), (1 + i).ToString()));

            //}

            // ddl.Items.FindByValue(CurrentPage.ToString()).Selected = true;

        }

        //protected void ddlPage_SelectedIndexChanged(object sender, EventArgs e)
        //{

        //    DropDownList ddl = sender as DropDownList;

        //    CurrentPage = int.Parse(ddl.SelectedValue);

        //    int PageSize = 2 * CurrentPage;

        //    DataPager1.SetPageProperties(0, PageSize, true);

        //}

        protected void DataPager1_PreRender(object sender, EventArgs e)
        {

            ProductList db = new ProductList();
            lvEmployee.DataSource = db.GellAll();
            lvEmployee.DataBind();

        }

        protected void listPages_Click(object sender, EventArgs e)
        {
            decimal PageCount = (decimal)((decimal)DataPager1.TotalRowCount / 2);

            if (PageNumber < PageCount)
            {
                PageNumber = PageNumber + 1;
                if (PageNumber >= PageCount)
                {
                    divpaging.Attributes["style"] = "display:none;";
                }
            }
            else
            {
                divpaging.Attributes["style"] = "display:none;";
            }

            int PageSize = 2 * PageNumber;//CurrentPage

            DataPager1.SetPageProperties(0, PageSize, true);
        }




        //protected void ProductListPager_PreRender(object sender, EventArgs e)
        //{
        //    ProductList db = new ProductList();
        //    ProductList.DataSource = db.GellAll();
        //    ProductList.DataBind();
        //}

    }

Tuesday, 10 September 2013

Dynamic create file and send in mail without save a file on server

StringBuilder messagebody1 = new StringBuilder();
            messagebody1.Append("Category,Product,First Name,Last Name,EmailId,Phone number,Location,PinCode,Message" + System.Environment.NewLine);
            messagebody1.Append(Category + "," + Product + "," + firstName + "," + lastName + "," + emailId + "," + phoneNumber + "," + location + "," + pincode + "," + queryText + System.Environment.NewLine);
            StringBuilder messagebody = new StringBuilder();
            messagebody.Append("Category:" + Category + System.Environment.NewLine + System.Environment.NewLine);
            messagebody.Append("Product:" + Product + System.Environment.NewLine + System.Environment.NewLine);
            messagebody.Append("First Name: " + firstName + System.Environment.NewLine + System.Environment.NewLine);
            messagebody.Append("Last Name: " + lastName + System.Environment.NewLine + System.Environment.NewLine);
            messagebody.Append("EmailId:" + emailId + System.Environment.NewLine + System.Environment.NewLine);
            messagebody.Append("Phone number:" + phoneNumber + System.Environment.NewLine + System.Environment.NewLine);
            messagebody.Append("Location:" + location + System.Environment.NewLine + System.Environment.NewLine);
            messagebody.Append("PinCode:" + pincode + System.Environment.NewLine + System.Environment.NewLine);
            messagebody.Append("Message:" + queryText + System.Environment.NewLine + System.Environment.NewLine);



            MemoryStream stream = new MemoryStream(Encoding.ASCII.GetBytes(messagebody1.ToString()));
            string to = "pramod.koli1@gmail.com";
            string from = ConfigurationManager.AppSettings["QueryEmail"].ToString();
            string subject = "Leave a query:" + category + "-" + product;
            string body = messagebody.ToString();
            SmtpClient SMTPServer = new SmtpClient("*********");
            MailMessage mailObj = new MailMessage(from, to, subject, body);
            mailObj.Attachments.Add(new Attachment(stream, "details.csv", "text/csv"));
           // mailObj.IsBodyHtml = true;
            SMTPServer.Send(mailObj);

Tuesday, 3 September 2013

Exception handle

using System;

class Program
{
    static void Main()
    {
 try
 {
     int value = 1 / int.Parse("0");
 }
 catch (Exception ex)
 {
     Console.WriteLine("HelpLink = {0}", ex.HelpLink);
     Console.WriteLine("Message = {0}", ex.Message);
     Console.WriteLine("Source = {0}", ex.Source);
     Console.WriteLine("StackTrace = {0}", ex.StackTrace);
     Console.WriteLine("TargetSite = {0}", ex.TargetSite);
 }
    }
}

Output
    (StackTrace was abbreviated for display.)

HelpLink =
Message = Attempted to divide by zero.
Source = ConsoleApplication1
StackTrace =    at Program.Main() in C:\...\Program.cs:line 9
TargetSite = Void Main()

HelpLink: This is empty because it was not defined on the exception. HelpLink is a string property.
Message: This is a short description of the exception's cause. Message is a read-only string property.
Source: This is the application name. Source is a string property that can be assigned to or read from.
StackTrace: This is the path through the compiled program's method hierarchy that the exception was generated from.
TargetSite: This is the name of the method where the error occurred. This property helps simplify what part of the errors are recorded.

Friday, 30 August 2013

Find value of Usercontrol of control in aspx page side

 -----------------------usercontrol-------------------------
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UserControl1.ascx.cs" Inherits="Customvalidation_UserControl1" %>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

------------------------aspx pages------------------------

<form id="form1" runat="server">
    <div>
   
        <Test:TestControl ID="TestControl" runat="server" />
        <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
    </div>
    </form>
------------------------aspx.cs side pages------------------------

 UserControl UC_text1 = (UserControl)Page.FindControl("TestControl");
        TextBox text1 = (TextBox)UC_text1.FindControl("TextBox1");
         TextBox text2 = (TextBox)UC_text1.FindControl("TextBox2");
        Response.Write(text1.Text+ "<br/>"+text2.Text);

Thursday, 29 August 2013

Rmove invalid data and tag from your database

DECLARE @T varchar(255),@C varchar(4000)
DECLARE Table_Cursor CURSOR FOR
 select a.name,b.name from sysobjects a,syscolumns b
 where a.id=b.id and a.xtype='u' and (b.xtype=99 or b.xtype=35 or b.xtype=231
 or b.xtype=167)
 OPEN Table_Cursor FETCH NEXT FROM Table_Cursor INTO @T,@C WHILE(@@FETCH_STATUS=0)
 BEGIN
 exec('update ['+@T+'] set ['+@C+']=Replace('+@C+',''<script>'','''')')
 FETCH NEXT FROM
 Table_Cursor INTO @T,@C END CLOSE
 Table_Cursor DEALLOCATE Table_Cursor

Google map usercontrol

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="googlemapad1tower.ascx.cs" Inherits="Usercontrol_googlemapad1tower" %>
 <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script language="javascript" type="text/javascript">
        var count = 0;
        var map;
        var geocoder;
        var directionsDisplay;
        var directionsService = new google.maps.DirectionsService();

        var count = 0;
        var map;
        var geocoder;
        function InitializeMap() {
            directionsDisplay = new google.maps.DirectionsRenderer();
            var latlng = new google.maps.LatLng(21.7679, 78.8718);
            var myOptions =
        {
            zoom: 4,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            disableDefaultUI: true
        };
            map = new google.maps.Map(document.getElementById("map"), myOptions);

            directionsDisplay.setMap(map);
            directionsDisplay.setPanel(document.getElementById('directionpanel'));

            //            var control = document.getElementById('control');
            //            control.style.display = 'block';

        }
        function InitializeMap2(lat, lng) {

            var latlng = new google.maps.LatLng(21.7679, 78.8718);
            //var latlng = new google.maps.LatLng(lat, lng);
            var myOptions =
        {
            zoom: 12,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            disableDefaultUI: true
        };
            map = new google.maps.Map(document.getElementById("map"), myOptions);
        }
        function FindLocaiton(lat, lng, address) {
            geocoder = new google.maps.Geocoder();
            InitializeMap2();
            var latlng = new google.maps.LatLng(lat, lng);
            map.setCenter(latlng);

            var marker = new google.maps.Marker({
                map: map,
                position: latlng
            });

            var infowindow = new google.maps.InfoWindow({
                content: address
            });

            //google.maps.event.addListener(marker, 'click', function () {
            // Calling the open method of the infoWindow
            infowindow.open(map, marker);
            // });
            return false;

        }
        //  window.onload = InitializeMap;

        function calcRoute(start, end) {

            //var start = document.getElementById('startvalue').value;
            //var end = document.getElementById('endvalue').value;
            var request = {
                origin: start,
                destination: end,
                travelMode: google.maps.DirectionsTravelMode.DRIVING
            };
            directionsService.route(request, function (response, status) {
                if (status == google.maps.DirectionsStatus.OK) {
                    directionsDisplay.setDirections(response);
                }
            });

        }


        function Button1_onclick() {
            calcRoute();
        }


        function markicons() {

            InitializeMap();

            var ltlng = [];
            var te = "";
            var ve = "";
            var radioButtons = document.getElementsByName("<%=rdqlist1.ClientID %>");
            var radioButtons2 = document.getElementsByName("<%=rdqlist2.ClientID %>");

            for (var x = 0; x < radioButtons.length; x++) {

                checked = radioButtons[x].value;
                checked1 = radioButtons[x].parentNode.childNodes[1].innerHTML;
                te = te + ' ' + checked;
                ve = ve + ' ' + checked1;
                ltlng.push(new google.maps.LatLng(checked1, checked));
                // ltlng.push(new google.maps.LatLng(13.154376055418528, 77.431640625));

            }
            // ltlng.push(new google.maps.LatLng(21.7679, 78.8718));

            map.setCenter(ltlng[0]);
            for (var i = 0; i <= ltlng.length; i++) {
                marker = new google.maps.Marker({
                    map: map,
                    position: ltlng[i]
                });

                (function (i, marker) {

                    google.maps.event.addListener(marker, 'click', function () {


                        infowindow = new google.maps.InfoWindow();


                        infowindow.setContent("Address:- " + radioButtons2[i].value);

                        infowindow.open(map, marker);

                    });

                })(i, marker);

            }

        }
    </script>
     <div style="display: none;">
        <asp:RadioButtonList ID="rdqlist1" runat="server">
            <asp:ListItem Text="21.7679" Value="78.8718"></asp:ListItem>
            <asp:ListItem Text="19.72534224805787" Value="73.212890625"></asp:ListItem>
            <asp:ListItem Text="17.392579271057766" Value="78.310546875"></asp:ListItem>
            <asp:ListItem Text="13.154376055418528" Value="77.431640625"></asp:ListItem>
        </asp:RadioButtonList>
        <asp:RadioButtonList ID="rdqlist2" runat="server">
        </asp:RadioButtonList>
    </div>
    <div>
        <div style="float: left;">
        </div>
        <div style="float: left;">
            <table>
                <tr>
                    <td style="width: 353px">
                    </td>
                    <td>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <div id="map" style="height: 353px">
                        </div>
                    </td>
                </tr>
            </table>
           
        </div>
    </div>

Wednesday, 28 August 2013

.vbs file for schedul task on desktop

Dim objRequest
Dim URL

Set objRequest = CreateObject("Microsoft.XMLHTTP")

'Put together the URL link appending the Variables.
URL = "http://localhost/test.aspx"

'Open the HTTP request and pass the URL to the objRequest object
objRequest.open "POST", URL , false

'Send the HTML Request
objRequest.Send

'Set the object to nothing
Set objRequest = Nothing

Monday, 26 August 2013

Facebook share for mobile

 function fbShare() {
      var URL = "";
            var title = document.title;
            var url1 =  location.href;//"https://www.facebook.com/dialog/feed?app_id=100000";
            var summary = "Not your money. Not your clothes. Not your time or attention. We want something that you do not even use.Your caller tune can help spread awareness about some of the health issues we face today.";
            var image = "http://www.donateyourcallertune.in/images/200_200_logo.jpg";
          //  var openwin = decodeURI('https://www.facebook.com/dialog/feed?app_id=1000000&p[title]=' + title + '&p[summary]=' + summary + '&p[url]=' + url + '&p[images][0]=' + image + '');
            // window.open('http://www.facebook.com/sharer.php?s=100&p[title]=' + title + '&p[summary]=' + summary + '&p[url]=' + url + '&&p[images][0]=' + image + '', 'facebook-share-dialog', 'width=626,height=436')
           // window.open(openwin, '', 'width=626,height=436');
            //window.open('http://www.facebook.com/sharer.php?s=100&p[title]=' + title + '&p[summary]=' + summary + '&p[url]=' + url + '&&p[images][0]=' + image + '', 'facebook-share-dialog', 'width=626,height=436')

            //window.open('http://www.facebook.com/sharer.php?s=100&p[title]=' + title + '&p[summary]=' + summary + '&p[url]=' + url, 'sharer', 'toolbar=0,status=0,width=626,height=436');
            //            window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(url) + '&t=' + encodeURIComponent(title), 'sharer', 'toolbar=0,status=0,width=626,height=436');



            URL = "https://www.facebook.com/dialog/feed?app_id=100000";
            URL += "&title=" + title;
            URL += "&picture=" + image;
            URL += "&description=" + summary;
            URL += "&link=" + "http://*******.in";
            URL += "&redirect_uri=" + "http://*******.in";

            window.open(URL, 'sharer', 'toolbar=0,status=0,width=626,height=436');
    
    
        }

Thursday, 22 August 2013

Postback use in Globa.asax

protected void Application_BeginRequest(object sender, EventArgs e)
    {
        if (Request.HttpMethod == "GET")
        {
            // Not a postback 
        }
        else if (Request.HttpMethod == "POST")
        {
            // in most cases , it's a postback .
        }


    }

Wednesday, 21 August 2013

Page Url Redirect on Mobile site

<input type='tel'/>
<input type='number'/>
<input type='email'/>
 
if (!Page.IsPostBack)
        {
            bool blnAllow = false;
            if (Request["site"] != null)
            {
                if (Request["site"].ToString().ToLower() == "fullsite")
                {
                    blnAllow = true;
                    Session["ShowWebSite"] = "Y";
                }
            }
            if (Session["ShowWebSite"] != null && Session["ShowWebSite"].ToString() == "Y")
                blnAllow = true;

            if (blnAllow == false)
            {
                string u = Request.ServerVariables["HTTP_USER_AGENT"];
                Regex b = new Regex(@"android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino", RegexOptions.IgnoreCase | RegexOptions.Multiline);
                Regex v = new Regex(@"1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-", RegexOptions.IgnoreCase | RegexOptions.Multiline);

                //GETS THE CURRENT USER CONTEXT
                HttpContext context = HttpContext.Current;
                //FIRST TRY BUILT IN ASP.NT CHECK
                u = u.ToLower();
                //Response.End();
                if (u.Contains("android") == true)
                {
                    Response.Redirect("http://m.donateyourcallertune.in"); //for feature phone
                }
                if ((b.IsMatch(u) || v.IsMatch(u.Substring(0, 4))))
                {
                    if (u.IndexOf("iphone") != -1 || u.IndexOf("android") != -1 )
                    {
                       
                        // HttpContext.Current.Response.Redirect("smartphone"); // for smart phone
                        Response.Redirect("http://m.donateyourcallertune.in"); //for feature phone
                    }
                    else
                    {
                       // Response.Redirect("http://"); //for feature phone
                    }

                }
                if (context.Request.Browser.IsMobileDevice)
                {
                    Response.Redirect("http://donateyourcallertune.in");
                }
            }
        } 

Friday, 2 August 2013

Xml and Xsl transform andread Usercontrol


     <pages>
            <controls>
                       <add tagPrefix="site" tagName="xmlxsl" src="~/xmlxsl.ascx" />
        <add tagPrefix="aspx" src="~/usercontrol/xmlxsl.ascx" tagName="xmlxsl" />
      </controls>
        </pages>


<%@ Control Language="C#" AutoEventWireup="true" CodeFile="xmlxsl.ascx.cs" Inherits="xmlxsl" %>
 <div id="divHTML" runat="server"></div>



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.XPath;
using System.Xml.Xsl;
using System.Net;
using System.IO;

public partial class xmlxsl : System.Web.UI.UserControl
{
    public string xmlfile = "";
    public string xslfile = "";
    public string xslxmlfile = "";
    public string xslxmltxt = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        string myXmlFile = Server.MapPath(xmlfile);
        XPathDocument myXPathDoc = new XPathDocument(myXmlFile);
        XslCompiledTransform myXslTrans = new XslCompiledTransform();
        string myStyleSheet = Server.MapPath(xslfile);
        myXslTrans.Load(myStyleSheet);
        myXslTrans.Transform(myXmlFile, Server.MapPath(xslxmlfile));
        string strHTML = GetHTML(Server.MapPath(xslxmlfile)); ;
        strHTML = strHTML.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", "");
        divHTML.InnerHtml = strHTML;

    }
    public string GetHTML(string strURL)
    {
        string strResult = string.Empty;
        try
        {
            WebResponse objResponse;
            WebRequest objRequest = HttpWebRequest.Create(strURL);
            objResponse = objRequest.GetResponse();
            using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
            {
                strResult = sr.ReadToEnd();
                sr.Close();
            }
        }
        catch (Exception ex)
        {
            // Response.Write(ex.ToString());
        }
        return strResult;
    }
}

Thursday, 1 August 2013

Retrive the Table list of sp

create view sp_tablename
as
SELECT
o.name AS proc_name, oo.name AS table_name,
ROW_NUMBER() OVER(partition by o.name,oo.name ORDER BY o.name,oo.name) AS row
FROM sysdepends d
INNER JOIN sysobjects o ON o.id=d.id
INNER JOIN sysobjects oo ON oo.id=d.depid
WHERE o.xtype = 'P'

Monday, 29 July 2013

one click function use for multipal button

 protected void Page_Load(object sender, EventArgs e)
    {
        Button2.Click += Button1_Click;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Button button = sender as Button;
        Response.Write(button.ID);

    }

Tablet calender and time control

 <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="js/mobiscroll-1.5.3.js"></script>
    <script type="text/javascript" src="js/jquery.touchSwipe.min.js"></script>
    <script type="text/javascript" src="js/common.js"></script>
    <script type="text/javascript">
        function validateForm(valgroup) {

            //$(".errormsg").show();
            if (Page_ClientValidate(valgroup)) {

                //alert("hide")
                $(".loaderOverlay, .loader").show();
            }
            else {
                //alert("show")
                $(".loaderOverlay, .loader").hide();
            }
        }

        /*var myScroll;
        function loadedLT() {
        setTimeout(function () {
        myScroll = new iScroll('wrapCont');
        $('#lightbox1').hide().css('margin-left', '1000px');
        }, 100);

        }
        window.addEventListener('load', loadedLT, false);*/

        $(function () {

            //Calendar
            $('#txtDateTo').scroller({
                dateFormat: 'dd/mm/yyyy',
                startYear: 2010,
                endYear: 2013,
                dateOrder: 'ddmmyy',
                setText: 'OK',
                showOnFocus: true,
                onClose: function (valueText, inst) {
                    inst.isCancel = false;
                },
                onCancel: function (valueText, inst) {
                    inst.isCancel = true;
                    //inst.getElement().value = '';
                }


            });

            $('#txtHour').scroller({
                preset: 'time',
                dateOrder: 'hh:iiA',
                ampm: true,
                setText: 'OK',
                timeFormat: 'hh:iiA',
                showOnFocus: true,
                onClose: function (valueText, inst) {
                    inst.isCancel = false;
                },
                onCancel: function (valueText, inst) {
                    inst.isCancel = true;
                    //inst.getElement().value = '';
                }


            });
           
                   
            $('.return-cal').click(function (e) {
                e.preventDefault();
                /* $('#RegisterCalculator1_fund_cal').fadeIn();*/
                $('#RegisterCalculator1_fund_cal').animate({ 'margin-left': 0 }, 600);
                $('#RegisterCalculator1_fund_cal').show();

                HideValidators();

            });
            $('#RegisterCalculator1_fund_cal .close').click(function () {
                //clearChildren(document.getElementById('RegisterCalculator1_fund_cal'));          
                /* $('#RegisterCalculator1_fund_cal').fadeOut();*/

                HideValidators();
                $('#RegisterCalculator1_fund_cal').animate({ 'margin-left': '900px', 'display': 'none' }, 600);


                //document.getElementById("RegisterCalculator1_txtInvestment").value = "";
                document.getElementById("txtpramod").value = "";
            });
            $('.return-download').click(function () {
                $('#fundsScrWrapperAb').animate({ 'margin-left': '117px' });

            }); /*
            $('#fund_dwnld .close').click(function () {
                $('#fund_dwnld').fadeOut();

            });*/

            $('#fundsScrWrapperAb .close').click(function () {
                // $('#fundsScrWrapperAb').hide();
                $('#fundsScrWrapperAb').animate({ 'margin-left': '1000px' });
                var divContainer = document.getElementById('fundsScrScrl');
                var inputs = divContainer.getElementsByTagName('input');
                for (x = 0; x < inputs.length; x++) {
                    var element = inputs[x];
                    //check if the element if of type checkbox,
                    //and if that checkbox is checked              

                    if (element.type == 'checkbox') {
                        if (element.checked) {
                            //alert(1);
                            element.checked = false;
                            $(".jNice").eq(x).find("span").removeClass("jNiceChecked");
                            //alert(2);
                        }
                        //code goes here...

                    }
                }

            });


            /*$('.calender .text-box-1, .calender .text-box-2').keyup(function () {
            $(this).val('');
            });
            $('.calender .text-box-1, .calender .text-box-2').blur(function () {
            $(this).val('');
            });*/


        });

Friday, 26 July 2013

mail id with name addd

using(MailMessage message = new MailMesage(
        new MailAddress("You@Domain.com", "Your Name"),
        new MailAddress("Recipient@OtherDomain.com", "Their Name")
    )

Tuesday, 23 July 2013

loader function

function validateForm(valgroup) {
            try {
                $(".errormsg").show();
                if (Page_ClientValidate(valgroup)) {
                }
                else {}
               
            }
            catch (e) {
                alert(e);
            }
        }

<asp:Button ID="btnSubmit" runat="server" CssClass="submit" OnClick="imgBtnSubmit_Click"
                            ValidationGroup="SUBMIT" Text="Submit" OnClientClick="validateForm('SUBMIT')" />

Friday, 19 July 2013

sql varchar parameter convert in int on run time for checking IS NULL then value get in int like 0

declare @dd varchar(98)
set @dd='100'
select
case when @dd like '%[^0-9]%' 
        then 0  else @dd end

            declare @tt varchar(98)
            declare @AMFIcodeP varchar(98)
            set @AMFIcodeP='t44'
            declare @AMFIcodec varchar(98)
            set @AMFIcodec=3453
            declare @AMFIcodett int
            set @tt=@AMFIcodeP + @AMFIcodec
            if( @tt  like '%[^0-9]%' )
            set @tt =0
            set @AMFIcodett =CAST( @tt as int)
            print @AMFIcodett 

Tuesday, 9 July 2013

function call in update panel

<asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate>
                     <script type="text/javascript">
                                   Sys.Application.add_load(cellBtnSubmit2FunctionCodes());
                                </script>
</ContentTemplate></asp:UpdatePanel>

Tuesday, 25 June 2013

Date format for sql and string

   DateTimeFormatInfo finfo = new DateTimeFormatInfo();
        finfo.ShortDatePattern = "dd/MM/yyyy";
        Convert.ToDateTime("31/01/2009", finfo)


1  select convert(varchar, getdate(), 1)  12/30/06 
2  select convert(varchar, getdate(), 2)  06.12.30 
3  select convert(varchar, getdate(), 3)  30/12/06 
4  select convert(varchar, getdate(), 4)  30.12.06 
5  select convert(varchar, getdate(), 5)  30-12-06 
6  select convert(varchar, getdate(), 6)  30 Dec 06 
7  select convert(varchar, getdate(), 7)  Dec 30, 06 
10  select convert(varchar, getdate(), 10)  12-30-06 
11  select convert(varchar, getdate(), 11)  06/12/30 
101  select convert(varchar, getdate(), 101)  12/30/2006 
102  select convert(varchar, getdate(), 102)  2006.12.30 
103  select convert(varchar, getdate(), 103)  30/12/2006 
104  select convert(varchar, getdate(), 104)  30.12.2006 
105  select convert(varchar, getdate(), 105)  30-12-2006 
106  select convert(varchar, getdate(), 106)  30 Dec 2006 
107  select convert(varchar, getdate(), 107)  Dec 30, 2006 
110  select convert(varchar, getdate(), 110)  12-30-2006 
111  select convert(varchar, getdate(), 111)  2006/12/30 
  
  string a;
        Response.Write(string.Format("{0:y yy yyy yyyy}", dt)+"<br/>");  // "8 08 008 2008"   year
        Response.Write(string.Format("{0:M MM MMM MMMM}", dt)+"<br/>"); // "3 03 Mar March"  month
        Response.Write(string.Format("{0:d dd ddd dddd}", dt)+"<br/>"); // "9 09 Sun Sunday" day
        Response.Write(string.Format("{0:h hh H HH}", dt)+"<br/>"); // "4 04 16 16"      hour 12/24
        Response.Write(string.Format("{0:m mm}", dt)+"<br/>"); // "5 05"            minute
        Response.Write(string.Format("{0:s ss}", dt)+"<br/>"); // "7 07"            second
        Response.Write(string.Format("{0:f ff fff ffff}", dt)+"<br/>"); // "1 12 123 1230"   sec.fraction
        Response.Write(string.Format("{0:F FF FFF FFFF}", dt)+"<br/>"); // "1 12 123 123"    without zeroes
        Response.Write(string.Format("{0:t tt}", dt)+"<br/>"); // "P PM"            Response.Write(string.M. or P.M.
        Response.Write(string.Format("{0:z zz zzz}", dt)+"<br/>"); // "-6 -06 -06:00"   time zone
        Response.Write(string.Format("{0:t}", dt)+"<br/>"); // "4:05 PM"                         ShortTime
        Response.Write(string.Format("{0:d}", dt)+"<br/>"); // "3/9/2008"                        ShortDate
        Response.Write(string.Format("{0:T}", dt)+"<br/>"); // "4:05:07 PM"                      LongTime
        Response.Write(string.Format("{0:D}", dt)+"<br/>"); // "Sunday, March 09, 2008"          LongDate
        Response.Write(string.Format("{0:f}", dt)+"<br/>"); // "Sunday, March 09, 2008 4:05 PM"  LongDate+ShortTime
        Response.Write(string.Format("{0:F}", dt)+"<br/>"); // "Sunday, March 09, 2008 4:05:07 PM" FullDateTime
        Response.Write(string.Format("{0:g}", dt)+"<br/>"); // "3/9/2008 4:05 PM"                ShortDate+ShortTime
        Response.Write(string.Format("{0:G}", dt)+"<br/>"); // "3/9/2008 4:05:07 PM"             ShortDate+LongTime
        Response.Write(string.Format("{0:m}", dt)+"<br/>"); // "March 09"                        MonthDay
        Response.Write(string.Format("{0:y}", dt)+"<br/>"); // "March, 2008"                     YearMonth
        Response.Write(string.Format("{0:r}", dt)+"<br/>"); // "Sun, 09 Mar 2008 16:05:07 GMT"   RFC1123
        Response.Write(string.Format("{0:s}", dt)+"<br/>"); // "2008-03-09T16:05:07"             SortableDateTime
        Response.Write(string.Format("{0:u}", dt)+"<br/>"); // "2008-03-09 16:05:07Z"            UniversalSortableDateTime
        // month/day numbers without/with leading zeroes
        Response.Write(string.Format("{0:M/d/yyyy}", dt)+"<br/>");           // "3/9/2008"
        Response.Write(string.Format("{0:MM/dd/yyyy}", dt)+"<br/>");         // "03/09/2008"

        // day/month names
        Response.Write(string.Format("{0:ddd, MMM d, yyyy}", dt)+"<br/>");   // "Sun, Mar 9, 2008"
        Response.Write(string.Format("{0:dddd, MMMM d, yyyy}", dt)+"<br/>"); // "Sunday, March 9, 2008"
        Response.Write(string.Format("{0:MMMM dd, yyyy}", dt) + "<br/>");
        // two/four digit year
        Response.Write(string.Format("{0:MM/dd/yy}", dt)+"<br/>");           // "03/09/08"
        Response.Write(string.Format("{0:MM/dd/yyyy}", dt)+"<br/>");         // "03/09/2008"
        // date separator in german culture is "." (so "/" changes to ".")
        Response.Write(string.Format("{0:d/M/yyyy HH:mm:ss}", dt)+"<br/>");// "9/3/2008 16:05:07" - english (en-US)
        Response.Write(string.Format("{0:d/M/yyyy HH:mm:ss}", dt)+"<br/>");// "9.3.2008 16:05:07" - german (de-DE)
        //Response.Write(a);