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'