Master page – reload/flickering

I’m afraid there’s no way to prevent the master page from reloading after

At run time, master pages are handled in the following sequence:
1. Users request a page by typing the URL of the content page.
2. When the page is fetched, the @ Page directive is read. If the directive
references a master page, the master page is read as well. If this is the
first time the pages have been requested, both pages are compiled.
3. The master page with the updated content is merged into the control tree
of the content page.
4. The content of individual Content controls is merged into the
corresponding ContentPlaceHolder control in the master page.
5. The resulting merged page is rendered to the browser.

From the browser’s point of view, it’s a single html page, so there’s no
way to only reload a part of it if it’s posted back.


How to Convert Seconds to HH:MM:SS

If you have a column that contains time in seconds and want to convert it to an hour : minute: seconds format, use this query. This query also takes care of displaying hours > 23.

DECLARE @SecondsToConvert int
SET @SecondsToConvert = 10000

— Declare variables
DECLARE @Hours int
DECLARE @Minutes int
DECLARE @Seconds int
DECLARE @Time datetime

— Set the calculations for hour, minute and second
SET @Hours = @SecondsToConvert/3600
SET @Minutes = (@SecondsToConvert % 3600) / 60
SET @Seconds = @SecondsToConvert % 60

— Store the datetime information retrieved in the @Time variable
RTRIM(CONVERT(char(8), @Hours) ) + ‘:’ +
CONVERT(char(2), @Minutes) + ‘:’ +
CONVERT(char(2), @Seconds));

— Display the @Time variable in the format of HH:MM:SS
SELECT CONVERT(varchar(8),CONVERT(datetime,@Time),108)

Invitatii nunta

Marriage Invitation…..(SQL Server Stored Procedure Style)

@BrideGroom Char(NotBad),
@Bride Char(Good)

FatherInLaw = ‘Millionaire’ AND
CarCount > 2 AND
HouseStatus =’TwoStoreyed’ AND
HavingBrothers=’NO’ AND
HavingSisters =’No’ AND
AllowRelocate =’YES’ AND

SELECT Gold, Cash, Car, BankBalance FROM FatherInLaw

UPDATE MyBankAccout SET MyBal = MyBal + FatherinLawBal
UPDATE MyLocker SET MyLockerContents = MyLockerContents + FatherinLawGold


Another marriage Invitation…

Poem Of A Software Engineer

Just know that the love I have for you
Is not to be put in a stack or queue
Like a variable in an infinite loop
Be in my heart always and never stop

My heart is like a port, unread,
and the love I have has only one thread
You are in my heart’s RAM and not in the cache
So if you won’t respond, my heart will crash.

Like an application that is stand alone,
I’m a programmer who earns a lot on my own
And my request is clear, without any encryption
And hope it is not void, that you return.

If Java can be linked with C
Or if e-mails can be sent for free
Why on earth can’t you and me
For the rest of our life time together be”

How To: Scale .NET Applications

Scalability refers to the ability of an application to continue to meet its performance objectives with increased load. Typical performance objectives include application response time and throughput. When measuring performance, it is important to consider the cost at which performance objectives are achieved. For example, achieving a sub – second response time objective with prolonged 100% CPU utilization would generally not be an acceptable solution.
This How To is intended to help you make informed design choices and tradeoffs that in turn will help you to scale your application. An exhaustive treatment of hardware choices and features is outside the scope of this document.
After completing this How To, you will be able to:

  • Determine when to scale up versus when to scale out.
  • Quickly identify resource limitation and performance bottlenecks.
  • Identify common scaling techniques.
  • Identify scaling techniques specific to .NET technologies.
  • Adopt a step-by-step process to scale .NET applications.
  • Scale Up vs. Scale Out

    There are two main approaches to scaling:
    Scaling up. With this approach, you upgrade your existing hardware. You might replace existing hardware components, such as a CPU, with faster ones, or you might add new hardware components, such as additional memory. The key hardware components that affect performance and scalability are CPU, memory, disk, and network adapters. An upgrade could also entail replacing existing servers with new servers.
    Scaling out. With this approach, you add more servers to your system to spread application processing load across multiple computers. Doing so increases the overall processing capacity of the system.

    Pros and Cons
    Scaling up is a simple option and one that can be cost effective. It does not introduce additional maintenance and support costs. However, any single points of failure remain, which is a risk. Beyond a certain threshold, adding more hardware to the existing servers may not produce the desired results. For an application to scale up effectively, the underlying framework, runtime, and computer architecture must also scale up.

    Scaling out enables you to add more servers in the anticipation of further growth, and provides the flexibility to take a server participating in the Web farm offline for upgrades with relatively little impact on the cluster. In general, the ability of an application to scale out depends more on its architecture than on underlying infrastructure.

    When to Scale Up vs. Scale Out
    Should you upgrade existing hardware or consider adding additional servers? To help you determine the correct approach, consider the following:

  • Scaling up is best suited to improving the performance of tasks that are capable of parallel execution. Scaling out works best for handling an increase in workload or demand.
  • For server applications to handle increases in demand, it is best to scale out, provided that the application design and infrastructure supports it.
  • If your application contains tasks that can be performed simultaneously and independently of one another and the application runs on a single processor server, you should asynchronously execute the tasks. Asynchronous processing is more beneficial for I/O bound tasks and is less beneficial when the tasks are CPU bound and restricted to a single processor. Single CPU bound multithreaded tasks perform relatively slowly due to the overhead of thread switching. In this case, you can improve performance by adding an additional CPU, to enable true parallel execution of tasks.
  • Limitations imposed by the operating system and server hardware mean that you face a diminishing return on investment when scaling up. For example, operating systems have a limitation on the number of CPUs they support, servers have memory limits, and adding more memory has less effect when you pass a certain level (for example, 4 GB).
  • Load Balancing
    There are many approaches to load balancing. This section contains a discussion of the most commonly used techniques.

    Web Farm
    In a Web farm, multiple servers are load balanced to provide high availability of service. This feature is currently only available in Windows® 2000 Advanced Server and Datacenter Server. Figure 1 illustrates this approach.

    Load balancing in a Web farm

    Load balancing in a Web farm


    for more see:

    Debugging client JavaScript in Visual Studio 2005

    Client Java Script is one of the most important things in web development but not the best and easiest to develop. Building of bigger and more complicated scripts, especially using DOM model or form field values can cause a lot of frustration and head pain. Moreover, JavaScript debugging is not easy and obvious as should be. But there is a hope.
    One of less known features of Visual Studio 2005 is Script Explorer, hidden in Debug menu where appears only when the debugger is running. This great tool allows easily debug JavaScripts.
    Before start, we should ensure that client script debugging is not disabled in IE as it is by default. Suitable options are located on Advanced tab of Internet Options where both script debugging checkboxes should be unchecked.


    We can come back to Script Explorer. As it was written before, it appears only while the debugger is working. So after starting project we can go do Debug->Windows where should be Script Explorer. Sometimes, don’t know why, it doesn’t so in this case we have to find it manually. Staying in debug mode right click on tool bar and go into Customize. Then select Debug in Categories on the left side of window and find Script Explorer on the right. Just drag it to Debugging toolbar.

    After opening Script Explorer panel we will se the tree of active JavaScripts. At the first level are scripts that are imported from external sources or embedded in the page. There are also auto-generated scripts like postback scripts as well. By double-clicking on the selected script it will open in the main window.

    At this moment, we can debug it in well known way using breakpoints, steps, Watch and QuickWatch, just like in the server side, including context browsing of a variable.

    Breakpoints can also be set up in external *.js files before project will be loaded. Then, after loading project, the breakpoint will be activated by debugger. Note, that it is only possible to *.js files not for scripts embedded in pages. These scripts are available for debugging only after loading page.


    Trim Leading Zeros Function

    Convert the VARCHAR column into an integer data type column then convert it back to VARCHAR and this will take care of trimming the leading zeros. You can either use the CAST function or the CONVERT function to convert the data type from type to another. I will use the CAST function as shown in the following:

    DECLARE @LeadingZeros VARCHAR(10)
    SET @LeadingZeros = ‘0000012345’
    SELECT @LeadingZeros AS [Leading0s],
    CAST(CAST(@LeadingZeros AS INT) AS VARCHAR(10))
    AS [Trimmed0s]

    The CAST(@LeadingZeros AS INT) took care of removing the leading zeros because integer values (or any numeric values) do not include any leading zeros in its value. Since the original data type was a VARCHAR, another CAST function was used to put it back to VARCHAR data type.
    However, executing this process over the actual table generated the following error:

    Server: Msg 245, Level 16, State 1, Line 3
    Syntax error converting the varchar value ‘0000123-45’ to a column of data type int.

    The problem: the column does not just contain numeric characters but also includes alphanumeric characters. To workaround this error, use the ISNUMERIC function so that  only trim the leading zeros of numeric values.

    UPDATE [dbo].[Customers]
    SET [CustomerKey] = CAST(CAST([CustomerKey] AS INT) AS VARCHAR(10))
    WHERE ISNUMERIC([CustomerKey]) = 1

    This would have been a good workaround but the requirement was to remove or trim the leading zeros of all records and not just those where the column was numeric. The next solution that I thought of was to simply replace all zeros with an empty string:

    UPDATE [dbo].[Customers]
    SET [CustomerKey] = REPLACE([CustomerKey], ‘0’, ”)

    This solution spelled trouble for me because it also replaced the 0’s that are inside the string and which are not part of the leading zeros. So, the value ‘000120-412′ became ’12-412’. Good thing I had a back-up and I was able to restore the table back to its original.

    After playing around with the different string functions available in SQL Server, I came up with the following solution:

    UPDATE [dbo].[Customers]
    SET [CustomerKey] = REPLACE(LTRIM(REPLACE([CustomerKey], ‘0’, ‘ ‘)), ‘ ‘, ‘0’)

    Basically it performs three steps:

    Replace each 0 with a space – REPLACE([CustomerKey], ‘0’, ‘ ‘)
    Use the LTRIM string function to trim leading spaces – LTRIM()
    Lastly, replace all spaces back to 0 – REPLACE(, ‘ ‘, ‘0’)
    This solution will only work if there are no spaces within the string, which is the case for me.

    User-Defined Function

    Now to make it easier to remember how to trim leading zeros from an alphanumeric string, we can make those 3 steps into a function, as follows:

    CREATE FUNCTION [dbo].[ufn_TrimLeadingZeros] ( @Input VARCHAR(50) )
    RETURN REPLACE(LTRIM(REPLACE(@Input, ‘0’, ‘ ‘)), ‘ ‘, ‘0’)

    User-Defined Function Extended

    The Trim Leading Zeros user-defined function can be extended so that it will not just trim leading zeros but it can also trim any character you want. By simply passing the character you want to trim as a parameter, the user-defined function can trim any leading character you specify:

    CREATE FUNCTION [dbo].[ufn_TrimLeadingCharacters] ( @Input VARCHAR(50), @LeadingCharacter CHAR(1) )
    RETURN REPLACE(LTRIM(REPLACE(@Input, ISNULL(@LeadingCharacter, ‘0’), ‘ ‘)),
    ‘ ‘, ISNULL(@LeadingCharacter, ‘0’))

    If you pass a NULL value for the @LeadingCharacter parameter, 0 is the character to be trimmed, as specified by ISNULL(@LeadingCharacter, ‘0’).

    (sursa: )

    Getting started with Windows Presentation Foundation

    Windows Presentation Foundation (formerly code named “Avalon”) is Microsoft’s unified presentation subsystem for Windows and is exposed through .NET Framework v3.0, Windows Vista’s managed-code programming model. Windows Presentation Foundation (WPF) consists of a display engine that takes full advantage of modern graphics hardware and an extensible set of managed classes that development teams can use to create rich, visually stunning applications. WPF also introduces Extensible Application Markup Language (XAML), which enables developers and designers to use an XML-based model to declaratively specify the desired user interface (UI) behavior. Windows Presentation Foundation provides a unified approach to user interface, 2D and 3D graphics, animation, documents and media. It allows designers to be an integral part of the application development process.

    Windows Presentation Foundation:

    • Allows you to:
      • Deliver innovative user interfaces rapidly
      • Increase designer-developer productivity using XAML’s declaritive programming model and WPF tools specifically designed for this designer-developer workflow
      • Leverage your existing code bases and design/development skill sets in building rich applications or controls   

    • Provides a managed code application development framework. Applications using Extensible Application Markup Language (XAML) currently support C# and Microsoft Visual Basic .NET. If you write a Windows Presentation Foundation application entirely in procedural code, you can use any compatible language.
    • Helps you build applications that consist of an Application object and a set of pages. The Application object enables you to handle top-level events, and share code and state between pages.
    • Uses XAML, a declarative markup language, to implement the user interface (UI) of each page. The markup elements control page layout, display text and images, interact with users, and so on. As users progress through the application, they navigate from page to page, much like a Web application.
    • Uses XAML to program the underlying Windows Presentation Foundation object model. Every tag maps to a class and every attribute to a property. When you compile your project, the XAML parser converts the markup into equivalent object model–based code. So, anything you do with XAML, you can also do by manipulating the object model with procedural code.
    • Supports XAML pages that contain both procedural code and markup. For example, if you want to handle an event that is raised by one of the XAML elements on the page, you use XAML to attach a handler to the event. You then implement the event handler in procedural code. Windows Presentation Foundation applications usually separate design from coding by putting the procedural code in a separate code-behind file.
    • Supports two types of applications:
      • XAML Browser Application—Deployed from a server and hosted in the browser. This application type runs in the Internet zone, which limits its access to system resources.
      • Windows Application—Hosted in a window and has full access to system resources.

      You typically use the same code with either application type as long as it does not violate the Internet zone permission set.


    Windows Presentation Foundation architecture

    Windows Presentation Foundation architecture