May 23, 2014

Save You Errors In A Notepad C#

You Could Write It Any Where You Want .
You Could Write It Inside Every Function If You Need To.

I Have Used It Under A Button Click

protected void Button1_Click(object sender, EventArgs e)
        {
            TestClass t = new TestClass();
            DateTime time =  DateTime.Now;
            
            try
            {
                throw new Exception("Sql Error");

            }
            catch (Exception error)
            {
                TextBox1.Text = "" + error.Message;
                t.errorLogger(time.ToString(), "Your Function Name", ""+error.Message);                
            }
        }

 I Have Created A Class Name TestClass and created a object above and 
 called the function inside the class.

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

namespace Error_Handling
{
    public class TestClass
    {
        public void errorLogger(string time,string functionName,string errorOccured)
        {
            string lines = "Time : " + time + "  | Function Name : " + functionName + "  | Error Occured : " + errorOccured;
            System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt", true);
            file.WriteLine(lines);

            file.Close();
        }
    }
}

You will have to specify the path of the notepad above.

May 20, 2014

Create a PopUp In Android

Include this Function in your class and call this function by 
providing the parameters for tittle and message you want to display.

private void sayMessage(String title, String msg) {

Dialog d = new Dialog(this);
d.setTitle(title);
TextView tv = new TextView(this);
tv.setText(msg);
d.setContentView(tv);
d.show();
}


call your function like this

sayMessage("Great","Wow I Made It Happen, Am Marvelous");


* You Will Have To Import Some Classes When You Put This Code.
* Press ctrl+shift+o   then it will automatically fix your imports

Switch Activity In An Android Application (Switch Screens)

In Android Screens Are Called As Activity.
Now I Will Teach You How To Switch Between Activity(Screens) On An Android Project..
Its Simple As ABC.

1. Go to the src folder in your application and expand it.
2. You will find your package which you has created before. Now Expand That.
3. Now open the java file relevant to your activity.
4. For example if you want to go to a new activity on a button click then.
    Make your button click event and then paste this code inside your button click function

* change current_activity_class_name.this to your current class.this  
* change next_activity_class_name to your next_class.class 

startActivity(new Intent(current_activity_class_name.this,next_activity_class_name.class));

* Use this if you want the current activity to be destroyed
finish(); 



* You Will Have To Import Some Classes When You Put This Code.
* Press ctrl+shift+o   then it will automatically fix your imports

JWT Token Decode Using Jquery

When it come to authentication we use many mechanism. Ones the user authenticated we must keep these details somewhere safe. So we can share...