Monday, October 29, 2012

How to Get IP Address of our own Machine..


string strHostName = "";
strHostName = System.Net.Dns.GetHostName();

IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(strHostName);

IPAddress[] addr = ipEntry.AddressList;

string ip= addr[addr.Length - 1].ToString();


If you want to Retrive True IP Address then


string IPAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (IPAddress == null) //may be the HTTP_X_FORWARDED_FOR is null
{
            IPAddress = Request.ServerVariables["REMOTE_ADDR"];//we can use REMOTE_ADDR
}



Tuesday, October 16, 2012

Triggering an Event in Jquery with hyperlink href is firing only first time.


Before some days back i have an issue with my Jquerry.I have an hover Event and in that i am Triggering an Click Event.but the Problem is that it execute only first it will not triggering second time.The code is like this

  $(document).ready(function () {
        $(".various1").fancybox().hover(function () {
                    this.click();
            });
        });

so this code is execute for first time when i hover the image.so Replace above code with this it will worked.


  $(document).ready(function () {

            $(".various1").fancybox().hover(function () {
               if (this.click) {
                    this.click();
                 
                } else if (document.createEvent) {
                    if (event.target !== this) {
                        var evt = document.createEvent("MouseEvents");
                        evt.initMouseEvent("click", true, true, window,
          0, 0, 0, 0, 0, false, false, false, false, 0, null);
                        var allowDefault = this.dispatchEvent(evt);
               
                    }
                }

            });
        });