Get Device info in windows phone development

Posted by Unknown 0 comments
Get Device info in windows phone development

In this post am going to explain you how get Device info information of windows phone 7 application

Here is very small code snippet which will get the Device info information 




 Public void GetDeviceInfo()  
 {  
 string DeviceUniqueId=Convert.ToBase64String((byte[])DeviceExtendedProperties.GetValue("DeviceUniqueId");  
  string DeviceModelName= null;  
       object theModel = null;  
  if (Microsoft.Phone.Info.DeviceExtendedProperties.TryGetValue("DeviceName", out theModel))  
    DeviceModelName= theModel as string;  
 }  

Hope this will helps you 
Labels:

Get OS Info of Windows phone

Posted by Unknown 0 comments
Get Operating system(OS) information in windows phone 7 application

In this post am going to explain you how get Operating system(OS) information of windows phone 7 application

Here is very small code snippet which will get the Operating system(OS)  information 


public string GetOSVersion()
{
 string  OSVersion=Environment.OSVersion.Version.ToString();
return OSVersion;
}


Hope this will helps you
Labels: ,

Get Version information of windows phone 7 application

Posted by Unknown 0 comments
Get Version information of windows phone 7 application

In this post am going to explain you how get version information of windows phone 7 application

Here is very small code snippet which will get the version information 

Public string GetVersionInfo()
{
String Assemblyinfo=Assembly.GetExecutingAssembly().FullName;
string[] versionInfo =Assemblyinfo.split(',');
string versionName=versionInfo[1];

return versionName;

}
Labels: ,

Handling large SQL queries with LINQ

Posted by Unknown 0 comments
Labels: ,

create the dynamic object list in c# (Expando object)

Posted by Unknown 0 comments
create the dynamic object list in c# (Expando object)

In this post am going to explain about creating dynamic object list using Expando Object

See the bellow implementation

var DynamicObjList = new List<dynamic>();
dynamic obj = new ExpandoObject();
obj.someDynamicFiledname= "some value"; 

If you want to add field name also dynamically use bellow

var objDictionary = obj as IDictionary<string, object>;
objDictionary .Add("your filedname","value");
objDictionary =objDictionary .ToDictionary(x => x.Key, x => x.Value);
DynamicObjList.Add(objDictionary );


hope this will helps you
Labels: ,

How to write extension methods for anonymous types?

Posted by Unknown 0 comments
In my Previous post  i have explained how to write extension method for known types.in this post am going to explain about writing extension for anonymous  types


public static class MyExtensions
{

    public static T ExpectedType<T>(this IEnumerable<T> seq)
    {
        var type = typeof(T);

        MethodInfo[] getters = type.GetProperties().Select(pi => pi.GetGetMethod()).ToArray();


      
        var args = new object[0];

        foreach (var item in seq)
        {
            for (int i = 0; i < getters.Length; i++)
            {
                //
                Object value = getters[i].Invoke(item, args);
                var str = value.ToString();

              // you can write your code here
            }


          
        }return T;
    }
}


Click Here to see how to implement Extension methods in C#?

Hope this will helps you
Labels:

How to write extension methods in C#?

Posted by Unknown 0 comments
How to write extension methods in C#?

In this post am going to explain you about how write the extension method in C#?

Here am giving simple example for writing extension method  for a string to capitalize the first character of the string.
see Example bellow

let us take a string 

string str="sample:;

i want to convert the str value to "Sample"   by extension method

like str.ToCapitalize(); which returns the "Sample" as out put

see the bellow implementation 
in order to do this we required a static class

     public static class StringExtensions
    {
        public static string ToCapitalize(this string str)
        {
            if (string.IsNullOrWhiteSpace(str))
            {
                return str;
            }

            if (str.Length == 1)
            {
                return str.ToUpper();
            }
            else
            {
                return str.Substring(0, 1).ToUpper() + str.Substring(1, str.Length - 1).ToLower();
            }
        }

     }

as per above implementation we will get extension for string as ToCapitalize,where ever we have string variable we will get ToCapitalize();  like  ToString() ;
Hope this will helps you.
Labels:

jquery pass form data to ajax by using (form.serialze())

Posted by Unknown 0 comments
jquery pass form data to ajax:

To pass the entire form data to ajax call with j query, here we have very simple code snippet



var data = $('YourFormId').serialize();
$.post('yourURL', data,function(succees){....});

or you use the bellow
var Mydata = $('YourFormId').serialize();
   $.ajax({
       type: "POST",
        url: "yourUrl",
        data: Mydata ,        success: function(response, textStatus, xhr) {
            alert("success");
        },
        error: function(xhr, textStatus, errorThrown) {
            alert("error");
        }
    });
Hope this will helps you
Labels:

jquery validate form before ajax post

Posted by Unknown 0 comments
jquery validate form before ajax post:

Use submit handler to validate your form in ajax submission


$(document).ready(function() {
    $('#FormId').validate({
        submitHandler: function(form) {
            $.post('/sample.aspx/getmethod', $('#FormId').serialize());        }
    });
}); 
See demo here
Labels:

Add values from dialog popup to parent page dynamically

Posted by Unknown 0 comments

Add values from dialog popup to parent page dynamically


use this line of code in jquery to get the values from the popup to the parent page:

if you want to display values in  in textbox of parent page use this:
 
  parent.top.$("input#txtEmpNo").val("EH0001");

or

if you want to display values in  in div tag of parent page use this:

parent.top.$("#txtEmpNo").html("EH001");

Hope this will helps you


Labels:

jquery dialog not opening in browser

Posted by Unknown 0 comments
while implementing jquery modal popup i got bug with crome and IE browser, where as its working fine in firefox.
there are so many ways to implement jquery model popup but best way to implement jquery popup is

see bellow code:
$(function () {

$("#foo1").click(function(){
  $("#bar1").dialog('open');
});


$("#bar1").dialog({
    autoOpen: false,
    width: 400,
    modal: true,
    resizable: false,
    buttons:{
            "Save": function(){
//this is optional you can implement your own functionality
                        $.post('remote_foo.aspx', $('#waka').serialize(), function(data){
                    $('#list').html(data);})
                    $(this).dialog("close");
                    $('.dial').val('');
                    $('.url').val('http://');

                    },


            "cancel": function(){
                $(this).dialog("close");
            }
        }//buttons ending
    }); //dialog ending


})// doc ready ending
go though the bellow links
http://stackoverflow.com/questions/9122008/why-is-this-jqueryui-dialog-not-working-in-ie9
http://stackoverflow.com/questions/12779789/jquery-ui-dialog-not-displaying-in-iehttp://forum.jquery.com/topic/jquery-dialog-sometimes-not-showing-in-google-chrome

Labels:

Windows Phone 8 isolated storage

Posted by Unknown 0 comments
Labels:

Regex find at least one of two characters

Posted by Unknown 0 comments
Labels: ,

web client request caching issue in wp7 app

Posted by Unknown 0 comments

jump list in windows phone 7

Posted by Unknown 0 comments

implementing stack in C with generic style

Posted by Unknown 0 comments

how to save image from web request in c#

Posted by Unknown 0 comments
How to save image from web request in c#:


In this article am going to explain you how to save an image  from web request:
In order to implement this please have a look at bellow code:


 HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(MyUrl);
            req .Timeout = 5000;
            req .ReadWriteTimeout = 19000;
            HttpWebResponse res = (HttpWebResponse)request.GetResponse();
            System.Drawing.Image img = System.Drawing.Image.FromStream(res.GetResponseStream());
            // Save the response to the output stream
  
            string path = "C:\\Myfolder\\sample.png";
            img.Save(path, System.Drawing.Imaging.ImageFormat.Png);

I hope this will helps you in dev
Labels: , ,
 
test