Search This Blog

Wednesday, 20 March 2013

Dynamically send WCF endpoint in Asp.net


  var Binding = new BasicHttpBinding();
                        Binding.Security.Mode = BasicHttpSecurityMode.None;
                        string url= @"WCF URL";
                        var endpoint = new EndpointAddress(url);
                        MailDropService.ServiceClient Client = new MailDropService.ServiceClient(Binding,endpoint);

Wednesday, 6 March 2013

To remove onclick event in linkbutton in jquery

 <a id="lnkDNC" href="javascript:MethodName();">Test</a>
function MethodName() {
jqcc('#lnk').fadeTo("fast", 0.15).removeAttr('href');

}

Tuesday, 5 March 2013

disable Refresh button on IE,firefox,chrome Browser Using Javascript


<body id="MyBody" onkeydown="return showKeyCode(event)">

function showKeyCode(e) {
   // debugger;
    var keycode;
    if (window.event)
        keycode = window.event.keyCode;
    else if (e)
        keycode = e.which;

    // Mozilla firefox
    if ($.browser.mozilla) {
        if (keycode == 116 || (e.ctrlKey && keycode == 82)) {
            if (e.preventDefault) {
                e.preventDefault();
                e.stopPropagation();
            }
        }
    }
    // IE
    else if ($.browser.msie) {
        if (keycode == 116 || (window.event.ctrlKey && keycode == 82)) {
            window.event.returnValue = false;
            window.event.keyCode = 0;
            window.status = "Refresh is disabled";
        }
    }
    else {
        switch (e.keyCode) {

            case 116: // 'F5'
                event.returnValue = false;
                event.keyCode = 0;
                window.status = "Refresh is disabled";
                break;

        }
    }
}

Monday, 4 March 2013

Allow only Numeric values in ASP.net Text box control using JavaScript

<script language="javascript" type="text/javascript">
        function onlyNumbers(evt) {
            var e = event || evt;
            var charCode = e.which || e.keyCode;

            if (charCode > 31 && (charCode < 48 || charCode > 57))
                return false;

            return true;

        }
    </script>


<asp:TextBox ID="txt" runat="server" MaxLength="3" onkeypress="return onlyNumbers();"></asp:TextBox>

Wednesday, 30 January 2013

To display number of sales for each day from begin date or Sql query to Group by day in sql server

SELECT DATEADD(DAY, DATEDIFF(DAY, 0, SMD.CreatedDate), 0) AS CreatedOn
    ,COUNT(SMD.CreatedDate) as [Count]       
    FROM TableName SMD
    GROUP BY DATEADD(DAY, DATEDIFF(DAY, 0, SMD.CreatedDate), 0)

Monday, 28 January 2013

How can you retrieve a reference to the current application domain?MCTS 70-536 Sample Example


A.  AppDomain ad = AppDomain.Current;
B.  AppDomain ad = Thread.GetDomain();
C.  AppDomain ad = Thread.CurrentThread.CurrentDomain;
D.  AppDomain ad = AppDomain.GetCurrentDomain();

Sunday, 27 January 2013

You need to ensure that when the ProcessingComplete event is raised, an instance of the ProcessComplete class is provided to event subscribers. Which base class should you use for the ProcessComplete class?



A. IEnumerable(Of Order)
B. CollectionBase
C. EventArgs
D. Attribute

You need to ensure that dates and numbers are displayed correctly for each user based on location. Which code segment should you add to line GL08 of the Global.asax file?



·         CultureInfo info = (CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
info = CultureInfo.CreateSpecificCulture(culture);
·         System.Globalization.CultureInfo cultureInfo = cultureInfo.GetCultureInfo(culture);
System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;
·         System.Globalization.CultureInfo cultureInfo = cultureInfo.CreateSpecificCulture();
(culture);System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;


·         Dim cultureInfo As System.Globalization.CultureInfo =
New System.Globalization.CultureInfo(culture)                             System.Threading.Thread.CurrentThread.CurrentCulture = cultureInfo

• You need to log an entry in a custom event log when the EmailSenderService service is started and stopped. What should you do? (Each correct answer presents part of the solution. Choose three.)



A. Add the following code segment to line PO22 of the Poller.vb file:
EventLog.WriteEntry("EmailSenderService", "Stopped", EventLogEntryType.Information)
B. Add the following code segment to line PO12 of the Poller.vb file:
EventLog.WriteEntry("EmailSenderService", "Started", EventLogEntryType.Information)
C. Add the following code segment to line PO22 of the Poller.vb file:
EventLog.WriteEntry("Application", "EmailSenderService:Stopped",
EventLogEntryType.Information)
D. Add the following code segment to line ES10 of the EmailSenderService.vb file:
EventLog.CreateEventSource("Application", "EmailSenderService")
E. Add the following code segment to line PO12 of the Poller.vb file:
EventLog.WriteEntry("Application", "EmailSenderService:Started",
EventLogEntryType.Information)
F. Add the following code segment to line ES10 of the EmailSenderService.vb file:
EventLog.CreateEventSource("EmailSenderService", "EmailLog")

Monday, 7 January 2013

To count total number of objects is created for any Class in c# or Asp.net

public class Class1
    {
        static int Count = 0;

        public Class1()
        {
            Count++;
        }

        ~Class1()
        {
            Count--;
        }

        public static int getCount()
        {
            return Count;
        }

    }

class Program
    {
        static void Main(string[] args)
        {

            Class1 obj;

            for (int i = 0; i < 10; i++)
            {
                obj = new Class1();
                Console.WriteLine("Current Count" + Class1.getCount());
            }

            Console.ReadLine();
        }
    }

To count controls Names in page in asp.net

foreach (Control c in Page.Controls)
        {
            if (c.Controls.Count > 0)
            {
                foreach (Control c2 in c.Controls)
                {
                    lbl.Text += c2.GetType().Name + "<br/>";                  
                }
            }
        }

Thursday, 3 January 2013

second highest salary in sql without using top and with using top in sql server


--Second hightest Salary without using top
SELECT* FROM emp e1
WHERE
2 = (SELECT COUNT(DISTINCT (e2.sal))FROM emp e2
WHERE e2.sal >= e1.sal)

SELECT TOP 1 sal
FROM (SELECT DISTINCT TOP 2 sal FROM emp ORDER BY sal DESC) a
ORDER BY sal

second lowest salary in sql without using top and with using top

--Second lowest Salary
SELECT * FROM emp e1
WHERE
2 = (SELECT COUNT(DISTINCT (e2.sal))FROM
emp e2 WHERE e2.sal <= e1.sal)

SELECT TOP 1 sal
FROM (SELECT DISTINCT TOP 2 sal FROM emp ORDER BY sal ) a
ORDER BY sal DESC
Just change the number u can get n th salary for Employee

with cts as
(
select Name,rn=ROW_NUMBER() over (order by Salary desc) from SalaryTable 
)
select Name from cts where rn in (2,5)



Monday, 31 December 2012

You work in a company, and need to send an email to a user, and a copy of that email to your manager. Which code should you use?


A.  MailMessage msg = new MailMessage();
msg.From = "from@yourcompany.com";
msg.To = "to@to.com, manager@yourcompany.com";
msg.Subject = "...";
msg.Body = "...";
SmtpClient client = new SmtpClient();
client.Send(msg);
B.  MailMessage msg = new MailMessage("from@yourcompany.com", "to@to.com");
msg.CC.Add(new MailAddress("manager@yourcompany.com"));
msg.Subject = "...";
msg.Body = "...";
SmtpClient client = new SmtpClient();
client.Send(msg);
C.  MailMessage msg = new MailMessage("from@yourcompany.com", "to@to.com");
msg.CC.Add(new MailAddress("manager@yourcompany.com"));
msg.Subject = "...";
msg.Body = "...";
SmtpClient client = new SmtpClient();
msg.Send(client);
D.  MailMessage msg = new MailMessage();
msg.From = "from@yourcompany.com";
msg.To = "to@to.com, manager@yourcompany.com";
msg.Subject = "...";
msg.Body = "...";
SmtpClient client = new SmtpClient();
msg.Send(client);