Feeds:
Posts
Comments

Archive for the ‘Asp.net’ Category

encrypt decrypt password asp.net?

encrypt decrypt password asp.net with c#.

Namespace

using System.Text;

private string Encryptdata(string password)
    {
        string strmsg = string.Empty;
        byte[] encode = new byte[password.Length];
        encode = Encoding.UTF8.GetBytes(password);
        strmsg = Convert.ToBase64String(encode);
        return strmsg;
    }

private string Decryptdata(string encryptpwd)
    {
        string decryptpwd = string.Empty;
        UTF8Encoding encodepwd = new UTF8Encoding();
        Decoder Decode = encodepwd.GetDecoder();
        byte[] todecode_byte = Convert.FromBase64String(encryptpwd);
        int charCount = Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
        char[] decoded_char = new char[charCount];
        Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
        decryptpwd = new String(decoded_char);
        return decryptpwd;
    }

string strpassword = Encryptdata(TextBox1.Text); //Enc

string strpassword = Decryptdata(TextBox1.Text); //Dec

Advertisements

Read Full Post »

pop up window in html5?

<html>
<head>
<style type=”text/css”>
.modalDialog
{
position: fixed;
font-family: Arial, Helvetica, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.8);
z-index: 99999;
opacity: 0;
-webkit-transition: opacity 400ms ease-in;
-moz-transition: opacity 400ms ease-in;
transition: opacity 400ms ease-in;
pointer-events: none;
}

.modalDialog:target
{
opacity: 1;
pointer-events: auto;
}

.modalDialog > div
{
width: 150px;
position: relative;
margin: 10% auto;
padding: 5px 20px 13px 20px;
border-radius: 10px;
background: #fff;
background: -moz-linear-gradient(#fff, #999);
background: -webkit-linear-gradient(#fff, #999);
background: -o-linear-gradient(#fff, #999);
height: 150px;
}

.close
{
background: #606061;
color: #FFFFFF;
line-height: 25px;
position: absolute;
right: -12px;
text-align: center;
top: -10px;
width: 24px;
text-decoration: none;
font-weight: bold;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
-moz-box-shadow: 1px 1px 3px #000;
-webkit-box-shadow: 1px 1px 3px #000;
box-shadow: 1px 1px 3px #000;
}

.close:hover
{
background: #00d9ff;
}
</style>
</head>
<body>
<a id=”openModal1″ href=”#openModal”><span>HTML 5 POP UP</span></a>
<div id=”openModal” class=”modalDialog”>
<div>
<a href=”#close” title=”Close”>X</a>
<h3>
Pop Window
</h3>
This is pop window in html5 without jquery .
<p>
</p>
</div>
</div>
</body>
</html>

Read Full Post »

  <script src=”http://maps.google.com/maps/api/js?v=3&sensor=false&#8221; type=”text/javascript”></script>   

<script language=”javascript” type=”text/javascript”>

        var map;
        var geocoder;
        function InitializeMap() {

           var latlng = new google.maps.LatLng(0, 0);
            var myOptions =
        {
            zoom: 6,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            disableDefaultUI: true
        };
        map = new google.maps.Map(document.getElementById(“map”), myOptions);
        }

        function FindLocaiton(address1) {
                   
            geocoder = new google.maps.Geocoder();
            InitializeMap();

            var address = address1;
            geocoder.geocode({ ‘address’: address }, function (results, status) {
                if (status == google.maps.GeocoderStatus.OK) {
                    map.setCenter(results[0].geometry.location);
                  var marker = new google.maps.Marker({
                       map: map,
                       position: results[0].geometry.location
                    });

                }
                else {
                    alert(“Geocode was not successful for the following reason: ” + status);
                }
            });

        }
 

</script>

page Desing
<div id=”map”  style=”width:600px; height:400px;”x”>
</div>

<div style=”float: left; width: 100%; margin-bottom: 20px;”>
<div style=”height:48px; padding:0px; line-height:48px; padding-left:68px;” id=”Addedproduct”  runat=”server”>

Find Your Local Stores:
<asp:TextBox ID=”txt_search”  runat=”server” ></asp:TextBox>
&nbsp;

<asp:button type=”Submit” runat=”server”  text=”Search”  style=”border: none;” id=”btn_Search”
onclick=”btn_Search_Click” ></asp:button>
</div>
</div>

Button Coding

 protected void btn_Search_Click(object sender, EventArgs e)
    {
       ClientScript.RegisterStartupScript(this.GetType(), “FindLocaiton”, string.Format(“FindLocaiton(‘{0}’);”, txt_search.Text), true);
    }

 

 

Read Full Post »

google map in asp.net?

prerequisite:

1)<script src=”http://maps.google.com/maps/api/js?v=3&sensor=false&#8221; type=”text/javascript”></script>

2) Database Structure

S.No Lattitude Longitude Cityname
1 27.19912 73.74092 Nagaur

Javascript Code:

<script src=”http://maps.google.com/maps/api/js?v=3&sensor=false&#8221; type=”text/javascript”></script>

<script type=”text/javascript”>

             var icon = new google.maps.MarkerImage(“http://maps.google.com/mapfiles/ms/micons/blue.png&#8221;,

            new google.maps.Size(32, 32), new google.maps.Point(0, 0),

            new google.maps.Point(16, 32));

        var center = null;

        var map = null;

        var currentPopup;

        var bounds = new google.maps.LatLngBounds();

          var rendererOptions = {

            draggable: true

        };

         var directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);

        var directionsService = new google.maps.DirectionsService();

        var australia = new google.maps.LatLng(28.64186, 77.29457);

           function addMarker(lat, lng, info) {

                            // alert(“lat=”+lat,+”ln=”+lng,info);

 

            var StoreNAme= lat.split(“{“);      

            var str = StoreNAme[0];

            var n = str.split(“:”);

            lat = n[0];

            lng = n[1];

            info = n[2];

            var pt = new google.maps.LatLng(lat, lng);

            bounds.extend(pt);

           

            var key = n[2];           

            key=key.replace(/ /g,”_”);

//pop box

            info= ‘<div style=”widht:300px;”><div style=”float:left; widht:30%;”><img src=”img_shop.png” style=”width: 57px;” ></div><div style=” widht:70%; margin-top: 3px;”><span>Store Name:</span><b><span>’+StoreNAme[1]+'</span></b><br /><span style=” margin-top: 5px;”>’+n[2]+'</span></div><div style=”float:left;  margin-top: 7px;”><input type=”hidden” id=”sourceAddress” name=”sourceAddress” value=’+key+’><input type=”text” size=”30″ id=”text_search” value=”” name=”txtarch”> <input type=”button” id=’+key+’  onclick=”myFunction(this)” value=”Get Direction” name=”bSearch”></div>’;

           

            var marker = new google.maps.Marker({

                position: pt,

                icon: icon,

                map: map

            });

           

            var popup = new google.maps.InfoWindow({

                content: info,

                maxWidth: 300,

                

            });

 

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

                if (currentPopup != null) {

                    currentPopup.close();

                    currentPopup = null;

                }

                                        

 

                popup.open(map, marker);

                currentPopup = popup;

            });

            google.maps.event.addListener(popup, “closeclick”, function () {

                //map.panTo(center);

                currentPopup = null;

            });

 

            google.maps.event.addListener(directionsDisplay, ‘directions_changed’,                   function () {

                          

                computeTotalDistance(directionsDisplay.directions);

            });

                           

 

        }


        function initMap() {


            map = new google.maps.Map(document.getElementById(“map”), {

                         

                center: new google.maps.LatLng(0, 0),

                zoom: 1,

                mapTypeId: google.maps.MapTypeId.ROADMAP

               /* mapTypeControl: false,

                mapTypeControlOptions: {

                    style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR

                },

                navigationControl: true,

                navigationControlOptions: {

                    style: google.maps.NavigationControlStyle.SMALL

                }*/

            });

                         

            center = bounds.getCenter();

            map.fitBounds(bounds);


        }

        function calcRoute(origin1,destination1) {


              var request = {

                origin: origin1,

                destination:destination1,

               // waypoints: [{ location: ‘jaipur, Rajasthan’ }],

                travelMode: google.maps.TravelMode.DRIVING

            };

            directionsService.route(request, function (response, status) {                  

                         if (status == google.maps.DirectionsStatus.OK) {

                               

                    directionsDisplay.setDirections(response);

                }

                else

                {

                   alert(“Location not Found”);

                }

 

            });

               directionsDisplay.setMap(map);

            directionsDisplay.setPanel(document.getElementById(‘directionsPanel’));

             var menu = document.getElementById(‘km’)

              menu.style.display=”block”;

              

        }

        function computeTotalDistance(result) {

            var total = 0;

            var myroute = result.routes[0];

            for (i = 0; i < myroute.legs.length; i++) {

                total += myroute.legs[i].distance.value;

            }

            total = total / 1000.

            document.getElementById(“total”).innerHTML = total + ” km”;

        }    

      

       function myFunction(obj)

        {     

        var textvalue=document.getElementById(“text_search”).value;

        var sourceAddress=document.getElementById(“sourceAddress”).value;

         sourceAddress=sourceAddress.replace(/_/g,” “);

              if(textvalue !=”)

            {                calcRoute(textvalue,sourceAddress);

            }

            else

            {

                alert(“Please Enter the Destination Address”);

            }    

        }

    </script>

ASPX Page HTML:

<div id=”map”  style=”width:600px; height:400px;”x”>
</div>

//Direction Div

<div id=”directionsPanel” style=”float: left; min-height: 0px; max-height: 432px;
overflow-y: scroll; width: 100%;”>
</div>

//total Distance

<div id=”km” style=”display: none;”>
<p>
Total Distance: <span id=”total”></span>
</p>
</div>

 

ASPX CODE.CS PAGE CODING

Fill data table from database in asp.net

 

First call the initMap() after calling this function addMarker() Will be Called.

if (dataTable.Rows.Count > 0)

        {

             ClientScript.RegisterStartupScript(this.GetType(), “initMap”, string.Format(“initMap();”), true);

            for (int i = 0; i < dataTable.Rows.Count; i++)

            {

                 if (dataTable.Rows[i][“latitude”].ToString() != “” && dataTable.Rows[i][“longitude”].ToString() != “”)

                {

                    string FinalAddress = dataTable.Rows[i][“Address1”].ToString() + “,” + dataTable.Rows[i][“StateName”].ToString() + “{” + dataTable.Rows[i][“StoreName”].ToString();

                     ClientScript.RegisterStartupScript(this.GetType(), “addMarker” + i, string.Format(“addMarker(‘{0}: {1}: {2}’);”, dataTable.Rows[i][“latitude”].ToString(), dataTable.Rows[i][“longitude”].ToString(), FinalAddress.ToString()), true);

                }

             }

        }

 

 

 

 

 

Read Full Post »

Namespace

using System.Data.SqlClient;

using CrystalDecisions.Shared;

using CrystalDecisions.CrystalReports.Engine;

UI Design

ui

Search Criteria have two option like start date to end date select and search.

Search Button coding

Connection cn = new Connection();
 //Button Click Code
   private void Search_Click(object sender, EventArgs e)
   {
     try
            {
            DataSet Ds_records = new DataSet();
            con = new SqlConnection(cn.getConnection());
            SqlDataAdapter da = new SqlDataAdapter(“Sp_DiscountTharapy_Report_datewise”, con);
            da.SelectCommand.CommandType = CommandType.StoredProcedure;
            da.SelectCommand.Parameters.Add(“@firstDate”, SqlDbType.DateTime).Value = dateTimePicker1.Text;
            da.SelectCommand.Parameters.Add(“@EndDate”, SqlDbType.DateTime).Value = dateTimePicker2.Text;
            da.SelectCommand.Parameters.Add(“@hospital_id”, SqlDbType.Int).Value = Authentication_log1.hospitalId;
            DataTable dt = new DataTable();
            da.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                rpt_Discounttheraphy_date_wise1.Load(Application.StartupPath + “//rpt_Discounttheraphy_date_wise.rpt”);
                rpt_Discounttheraphy_date_wise1.SetDataSource(dt);
                //from date optional fields
                ParameterFieldDefinitions crParameterFieldDefinitions;
                ParameterFieldDefinition crParameterFieldDefinition;
                ParameterValues crParameterValues = new ParameterValues();
                ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
                crParameterDiscreteValue.Value = dateTimePicker1.Text;
                crParameterFieldDefinitions = rpt_Discounttheraphy_date_wise1.DataDefinition.ParameterFields;
                crParameterFieldDefinition = crParameterFieldDefinitions[“test”];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
                // To date optional parameters
                ParameterFieldDefinitions crParameterFieldDefinitions1;
                ParameterFieldDefinition crParameterFieldDefinition1;
                ParameterValues crParameterValues1 = new ParameterValues();
                ParameterDiscreteValue crParameterDiscreteValue1 = new ParameterDiscreteValue();
                crParameterDiscreteValue1.Value = dateTimePicker2.Text;
                crParameterFieldDefinitions1 = rpt_Discounttheraphy_date_wise1.DataDefinition.ParameterFields;
                crParameterFieldDefinition1 = crParameterFieldDefinitions1[“Todate”];
                crParameterValues1 = crParameterFieldDefinition1.CurrentValues;
                crParameterValues1.Clear();
                crParameterValues1.Add(crParameterDiscreteValue1);
                crParameterFieldDefinition1.ApplyCurrentValues(crParameterValues1);
                cry_main_report.ReportSource = rpt_Discounttheraphy_date_wise1;
                cry_main_report.Visible = true;
            }
            }
            catch(SqlException ee) {
                MessageBox.Show(“No record Found:”+ee.Message);
            }
        }

Just for Example.

pass textbox value to crystal report?

   ParameterFieldDefinitions crParameterFieldDefinitions1;

                ParameterFieldDefinition crParameterFieldDefinition1;

                ParameterValues crParameterValues1 = new ParameterValues();

                ParameterDiscreteValue crParameterDiscreteValue1 = new ParameterDiscreteValue();              

                crParameterDiscreteValue1.Value =Textbox value;

                crParameterFieldDefinitions1 = rpt_Discounttheraphy_date_wise1.DataDefinition.ParameterFields;

                crParameterFieldDefinition1 = crParameterFieldDefinitions1[“Todate”];

                crParameterValues1 = crParameterFieldDefinition1.CurrentValues;

                crParameterValues1.Clear();

                crParameterValues1.Add(crParameterDiscreteValue1);

                crParameterFieldDefinition1.ApplyCurrentValues(crParameterValues1);

 

 

 

 

Read Full Post »

Globel Class:

//Namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;

public class Globel
{

public Globel()
{
//
// TODO: Add constructor logic here
//
}

//Declaration of Hastable

public static int i = 5;
private static Hashtable globalhashtable_ = new Hashtable();
//Create Hastable
public static Hashtable globalhashtable
    {
                      get { return globalhashtable_; }

    }

//REMOVE FROM HASHTABLE
  public static bool RemoveItemfromList(string RemoveItemKey)
    {
        if (globalhashtable.Contains(RemoveItemKey.Trim()))
        {
            globalhashtable.Remove(RemoveItemKey.Trim());
            return true;
        }
        return false;
    }
//GET VALUE FROM HASTABLE
   public static string productAttrvaluebyID(string productUD)
    {
        if (globalhashtable.Contains(productUD.Trim()))
        {
            if (globalhashtable.ContainsKey(productUD.Trim()))
            {
                return globalhashtable[productUD].ToString();
            }
            else
            {
                return string.Empty;
            }
        }
        else
        {
            return string.Empty;
        }
    }
}

Code Behind Code:

Add Value to Hastable Like

  Globel.globalhashtable.Add(“Id”,500);

               Globel.globalhashtable.Add(“Key”,600);
   Remove Value from Hastable Like

        Globel.RemoveItemfromList(500);

  Get Value from Hastable Like

    string productAttribute =string.Empty ; 

    productAttribute = Globel.productAttrvaluebyID(productID.ToString());

That is it.

!!Happy Coding..

 

Read Full Post »

<script>
var str=”Raman(Ghantiy.ala”;

var Strfilter= str.substr(str.lastIndexOf(‘(‘) + 1, str.lastIndexOf(‘.’));

alert(Strfilter);

</script>

if we have this  Raman(Ghantiy.ala  string we want to substring from it. simply lastIndexOf will help us.

Ouput:

Ghantiy

 

Read Full Post »

Older Posts »