c# setting xmlns root attribute serialization

İf you want to  set xmlns attribute when serialization process you can  use XmlRoot attribute namespace .


[XmlRoot(Namespace= @”http://schemas.microsoft.com/sharepoint/”) ]

public class Elements


public Elements()



private string _ID;


public string ID


get { return _ID; }

set { _ID = value; }



happy tips..

Get URL without QueryString in ASP.NET

Is there an easy way to get the url part without the query string of a given Url?

Yeap .

string  sample = Request.Url.GetLeftPart(UriPartial.Path);

Or long way:

string stringUri = “https://blog.bugrapostaci.com/test.aspx?lang=en”;
Uri uri = new Uri(stringUri);
string query = uri.Query;
string url = stringUri.Substring(0, stringUri.Length – query.Length);

happy tips.bye.

Asp.net Disable postback LinkButton

Add fallowing code to your page_load HTML:

<asp:LinkButton ID="myLinkButton" runat="server" Text="Click Me"></asp:LinkButton>

protected void Page_Load(object sender, EventArgs e)
myLinkButton.Attributes.Add("onClick", "return false;");

Happy tips&tricks :)

c# Single instance of an application on one machine

Some times you want one running instance for your application then you can deny another running instance with this code.

using System;
using System.Threading;
using System.Windows.Forms;
namespace MyApp
    static class Program
        static Mutex _Mutex = null;
        static void Main()
            bool myAppFirstInstance;
            _Mutex = new Mutex(true, "Global\\MyApp ", out myAppFirstInstance);
            if (myAppFirstInstance)
                Application.Run(new MainForm());
                MessageBox.Show("There is already exists a running instance of this application",
                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

c# Use As , not is in

In C#, use as, not is. The is keyword is used to see whether a reference can be cast as particular type, but it doesn’t return a reference converted to that type. So usually, if you get a positive result from the is, the first thing you’ll do is a cast—effectively implementing the same cast twice. With the as keyword, a reference cast as the new type is returned if it’s valid and a null is returned if it’s not. You then can check for the null and do what you like. The asapproach is fully 50% faster than the is approach.