AJAX Tutorials


  1. AJAX security – read about AJAX security issues and vulnerability postings
  2. jQuery plugins – a directory of plugins for jQuery.
  3. How jQuery works – a basic jQuery tutorial.
  4. Tutorial: AJAX Made Easy – On the heels of two very successful tutorials on creating a collapsible div and an animated sliding div, I’ve decided to write another. It seems my last few helped a number of programmers learn a simple trick, and hopefully this one will do the same.
  5. Efficient JavaScript code – Opera has one of the fastest and most efficient JavaScript engines of any browser, but when you have multiple User JavaScripts installed, it is important that they run efficiently to keep Opera’s performance as high as possible. Well written code will help to minimise the performance impact of User JavaScripts.
  6. Create a photo gallery using CSS – This sample chapter, taken from Sams Teach Yourself CSS in 10 Minutes, discusses how to create a photo gallery using a series of floated div elements.
  7. Developing PHP the Ajax way, Part 2: Back, Forward, Reload – A major challenge of Asynchronous JavaScript and XML (Ajax)-driven Web sites is the lack of a Back button. We will use JavaScript to create a history stack for the Ajax photo gallery built in Part 1 of this two-part “Developing PHP the Ajax way” series. This history stack will closely mirror the history utility found in Web browsers, and it will be used to provide Back, Forward, and Reload buttons for the application.
  8. 30 second AJAX tutorial – as simple as they get
  9. Ajax: What is it Good For? – sliding interface and image gallery code examples
  10. AJAX: Creating Huge Bookmarklets – A bookmarklet is a special piece of JavaScript code that can be dragged into a user’s link toolbar, and which later can be clicked on to implement cross-site behavior. People have done all sorts of cool stuff with it.
  11. AJAX Tutorial with Prototype – I wanted to give an example of a good use of AJAX, and at the same time keep it simple. So I thought a good example would be to build a zip code verifier. As soon as the person enters the zip code it makes a request to the server to see if the zip code is in the database, and returns the city and state.
  12. AJAX Tutorial from W3Schools – very basic one
  13. AJAX:Getting Started – from Mozilla Developer Center
  14. Guide to Using AJAX and XMLHttpRequest – Although the XMLHttpRequest object might sound complex and different from any other JavaScript object you have ever used, it really isn’t. A good way to think of the XMLHttpRequest object is as you would think of the JavaScript Image object. As we know, with the Image object you can dynamically specify a new URL for the image source without reloading the page. Similarly with the XMLHttpRequest object, you can dynamically specify a URL to get some server data without reloading the page.
  15. AJAX: Usable Interactivity with Remote Scripting – This article aims to give you an introduction to the foundations of remote scripting, in particular, the emerging XMLHttpRequest protocol. We’ll then walk through an example application that demonstrates how to implement that protocol, while creating a usable interface.
  16. Ajax Tutorial from HTMLSource – includes a guide to cross-browser AJAX
  17. Make an AJAX Website in Less than 10 Minutes – I’ve been toying around with AJAX apps and XMLHttpRequest but have wanted to put up a site that loads all of its content asynchronously. If you’re like me and you learn best from working with examples you’re only 10 minutes away from your first AJAX website.
  18. Make all your tables sortable with AJAX – While the web design community gradually moves away from using tables to lay out the structure of a page, tables really do have a vital use, their original use; they’re for laying out tabular data.
  19. Using Ajax with PHP and Sajax – For years, the goal of creating a truly responsive Web application was hampered by one simple fact of Web development: To change the information on part of a page, a user must reload the entire page. Not anymore. Thanks to asynchronous JavaScript and XML (Ajax), we can now request new content from the server and change just part of a page. This tutorial explains how to use Ajax with PHP and introduces the Simple Ajax Toolkit (Sajax), a tool written in PHP that lets you integrate server-side PHP with JavaScript that makes this work.
  20. Learn xajax in 10 Minutes – xajax is designed to be extremely easy to implement in both existing web applications as well as new projects.
  21. Nice forms with AJAX – Web forms. Everybody knows web forms. Each day we have to fill in some information in a web form, be it a simple login to your webmail application, an online purchase or signing up for a website. They are the basic (and pretty much the only) way of gathering information on the web.
  22. Submit a form with Ajax – for CakePHP
  23. Building a Drag-and-Drop Shopping Cart with AJAX – The rise of AJAX over the past several months has taken over the development world and breathed new life into the Web. Although these techniques have been possible for many years now, the maturity of Web standards like XHTML and CSS now make it a viable alternative that will be viewable by all but the oldest browsers.
  24. Drag & Drop Sortable Lists with JavaScript and CSS – self-explanatory
  25. Mastering Ajax: Advanced requests and responses in Ajax – For many Web developers, making simple requests and receiving simple responses is all they’ll ever need, but for developers who want to master Ajax, a complete understanding of HTTP status codes, ready states, and the XMLHttpRequest object is required. In this article, Brett McLaughlin will show you the different status codes and demonstrate how browsers handle each and he will showcase the lesser-used HTTP requests that you can make with Ajax.
  26. AJAX: Instant Tutorial – Simply put, AJAX allows you to make a call to an http server (typically an RSS feed or a webpage), get it’s content and load them into your existing page without having to refresh the whole page. This means that services like email don’t have to reload the whole page everytime you click a message, saving on bandwidth (loading the header/footer all over again) and making things more efficient.
  27. Mastering Ajax: Make asynchronous requests with JavaScript and Ajax – Most Web applications use a request/response model that gets an entire HTML page from the server. The result is a back-and-forth that usually involves clicking a button, waiting for the server, clicking another button, and then waiting some more. With Ajax and the XMLHttpRequest object, you can use a request/response model that never leaves users waiting for a server to respond. In this article, Brett McLaughlin shows you how to create XMLHttpRequest instances in a cross-browser way, construct and send requests, and respond to the server.
  28. Alternate Ajax Techniques – By now, nearly everyone who works in web development has heard of the term Ajax, which is simply a term to describe client-server communication achieved without reloading the current page. Most articles on Ajax have focused on using XMLHttp as the means to achieving such communication, but Ajax techniques aren’t limited to just XMLHttp. There are several other methods; we’ll explore some of the more common ones in this series of articles.
  29. Everything AJAX – relevant links
  30. 50 AJAX toolkits and frameworks – a great roundup
  31. YShout – a PHP+AJAX Shoutbox
  32. Easy AJAX inline text edit – As everybody knows, refreshing pages is so 1999. AJAX, DOM, whatever you call it makes it possible to let people edit a piece of text inline without having to use a submit button.
  33. Developing AJAX Applications the Easy Way – AJAX is the buzzword of the moment among web developers, so much so that you could be sick of introductions to AJAX by now (if that’s the case, skip down to “The Chat Web Page”). AJAX is a technology that is hotly debated from many angles, but it has stuck because it encapsulates something that is new from a user’s perspective. The functionally that is newly available to all web users is “in-page replacement”: the ability for a web page to change using data from a web server without totally redrawing itself. This functionality has been around in Mozilla and Internet Explorer for a while, but it is only recently that Safari and Konqueror users have been able to join in.
  34. The Dojo Toolkit in Practice – When you start to build an Ajax application, you quickly run into situations where you feel like you are reinventing the wheel. The XMLHttpRequest object is what a lot of developers jump on when they think about Ajax, but that is just the start, and is the easy part.
  35. prototype.js just for AJAX – prototype.js library is too large for just using AJAX. In its current version (1.4.0_pre10) it weighs 36KB and contains lots of other features that are most probably not needed when just dealing with AJAX.
  36. Google Web Toolkit – Google Web Toolkit (GWT) is a Java software development framework that makes writing AJAX applications like Google Maps and Gmail easy for developers who don’t speak browser quirks as a second language. Writing dynamic web applications today is a tedious and error-prone process; you spend 90% of your time working around subtle incompatibilities between web browsers and platforms, and JavaScript’s lack of modularity makes sharing, testing, and reusing AJAX components difficult and fragile.
  37. ASK – AJAX Source Kit – The thing with AJAX is that it needs JavaScript to work and a direct consequence surrounding its hype is that a lot of web sites have implemented it without catering to common usability and accessibility factors. This is something that has saddened me, and therefore I developed ASK – AJAX Source KIT to address that while at the same time offer a light-weight library to implement AJAX functionality without having to worry about web browser differences.
  38. AJAX validation on Rails – I wanted AJAX requests in Rails to result in error handling and message reporting that was at least as nice (and almost as easy) as doing the same thing without AJAX.
  39. Responsible asynchronous scripting – Asynchronous or remote scripting has been lurking in the background of web app development for quite some time now. Originally dependent on proprietary technology like Java applets, ActiveX and Flash or clever combinations of disparate technologies like images and cookies, native support for the XMLHttpRequest (XHR) object in modern browsers has made it easier than ever to make web apps more responsive and more like their desktop counterparts. This lower barrier to entry also makes it easier to make poor decisions and inappropriate use of a powerful technology.
  40. Ajax RSS reader – Learn how to build an Asynchronous JavaScript and XML (Ajax) Really Simple Syndication (RSS) reader, as well as a Web component that you can place on any Web site to look at the articles in the RSS feeds.
  41. Creating a MySQL connection with PHP/AJAX – In this tutorial I will explain how to open a mysql database connection using PHP and the all popular AJAX. The purpose of this article is to demonstrate how the XMLHttpRequest object works within php and the advantages of using it. This tutorial will be the first in a series of articles leading to the development of a fully functional dynamic web events application.
  42. Getting Started with Ajax – The DOM plays into Ajax in a number of ways. How you use the DOM depends a good deal on how you handle the content returned from the server. You can treat the con­tent as simple text using the responseText property of the server response, or you can treat it as XML using responseXML. Assuming the content you pull back from the server is an (X)HTML snippet and you’ve gotten it as responseText, you could drop that content into a particular spot on the page using innerHTML. On the flip side, if the content you pull back is XML and you’ve gotten it as responseXML, you can traverse its DOM, cherry-picking or performing functions on the elements, attributes, and text nodes.
  43. Using Ajax from Perl – If you’re even remotely connected to web development, you can’t have failed to have heard of Ajax at some point in the last year. It probably sounded like the latest buzzword and was one of those things you stuck on the “must read up on later” pile. While it’s definitely a buzzword, it’s also quite a useful one.

 

JavaScript interview questions and answers


  • What’s relationship between JavaScript and ECMAScript? – ECMAScript is yet another name for JavaScript (other names include LiveScript). The current JavaScript that you see supported in browsers is ECMAScript revision 3.
  • What are JavaScript types? – Number, String, Boolean, Function, Object, Null, Undefined.
  • How do you convert numbers between different bases in JavaScript? – Use the parseInt() function, that takes a string as the first parameter, and the base as a second parameter. So to convert hexadecimal 3F to decimal, use parseInt (“3F”, 16);
  • What does isNaN function do? – Return true if the argument is not a number.
  • What is negative infinity? – It’s a number in JavaScript, derived by dividing negative number by zero.
  • What boolean operators does JavaScript support? – &&, || and !
  • What does “1”+2+4 evaluate to? – Since 1 is a string, everything is a string, so the result is 124.
  • How about 2+5+”8″? – Since 2 and 5 are integers, this is number arithmetic, since 8 is a string, it’s concatenation, so 78 is the result.
  • What looping structures are there in JavaScript? – for, while, do-while loops, but no foreach.
  • How do you create a new object in JavaScript? – var obj = new Object(); or var obj = {};
  • How do you assign object properties? – obj[“age”] = 17 or obj.age = 17.
  • What’s a way to append a value to an array? – arr[arr.length] = value;
  • What is this keyword? – It refers to the current object.
  •  

    ASP.NET interview questions and answers


    1. Describe the difference between a Thread and a Process?
    2. What is a Windows Service and how does its lifecycle differ from a “standard” EXE?
    3. What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memory for the system? How would this affect a system design?
    4. What is the difference between an EXE and a DLL?
    5. What is strong-typing versus weak-typing? Which is preferred? Why?
    6.  

    7. What’s wrong with a line like this? DateTime.Parse(myString
    8. What are PDBs? Where must they be located for debugging to work?
    9. What is cyclomatic complexity and why is it important?
    10. Write a standard lock() plus double check to create a critical section around a variable access.
    11. What is FullTrust? Do GAC’ed assemblies have FullTrust?
    12. What benefit does your code receive if you decorate it with attributes demanding specific Security permissions?
    13. What does this do? gacutil /l | find /i “about”
    14. What does this do? sn -t foo.dll
    15. What ports must be open for DCOM over a firewall? What is the purpose of Port 135?
    16. Contrast OOP and SOA. What are tenets of each
    17. How does the XmlSerializer work? What ACL permissions does a process using it require?
    18. Why is catch(Exception) almost always a bad idea?
    19. What is the difference between Debug.Write and Trace.Write? When should each be used?
    20. What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not?
    21. Does JITting occur per-assembly or per-method? How does this affect the working set?
    22. Contrast the use of an abstract base class against an interface?
    23. What is the difference between a.Equals(b) and a == b?
    24. In the context of a comparison, what is object identity versus object equivalence?
    25. How would one do a deep copy in .NET?
    26. Explain current thinking around IClonable.
    27. What is boxing?
    28. Is string a value type or a reference type?

     

    C# interview questions and answers


    1. What’s the advantage of using System.Text.StringBuilder over System.String? StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it’s being operated on, a new instance is created.
    2.  

    3. Can you store multiple data types in System.Array? No.
    4. What’s the difference between the System.Array.CopyTo() and System.Array.Clone()? The first one performs a deep copy of the array, the second one is shallow.
    5. How can you sort the elements of the array in descending order? By calling Sort() and then Reverse() methods.
    6. What’s the .NET datatype that allows the retrieval of data by a unique key?HashTable.
    7. What’s class SortedList underneath? A sorted HashTable.
    8. Will finally block get executed if the exception had not occurred? Yes.
    9. What’s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception? A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.
    10. Can multiple catch blocks be executed? No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block.
    11. Why is it a bad idea to throw your own exceptions? Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project.
    12. What’s a delegate? A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.
    13. What’s a multicast delegate? It’s a delegate that points to and eventually fires off several methods.
    14. How’s the DLL Hell problem solved in .NET? Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly.
    15. What are the ways to deploy an assembly? An MSI installer, a CAB archive, and XCOPY command.
    16. What’s a satellite assembly? When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.
    17. What namespaces are necessary to create a localized application?System.Globalization, System.Resources.
    18. What’s the difference between // comments, /* */ comments and /// comments? Single-line, multi-line and XML documentation comments.
    19. How do you generate documentation from the C# file commented properly with a command-line compiler? Compile it with a /doc switch.
    20. What’s the difference between <c> and <code> XML documentation tag? Single line code example and multiple-line code example.
    21. Is XML case-sensitive? Yes, so <Student> and <student> are different elements.
    22. What debugging tools come with the .NET SDK? CorDBG – command-line debugger, and DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch.
    23. What does the This window show in the debugger? It points to the object that’s pointed to by this reference. Object’s instance data is shown.
    24. What does assert() do? In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.
    25. What’s the difference between the Debug class and Trace class? Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.
    26. Why are there five tracing levels in System.Diagnostics.TraceSwitcher? The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities.
    27. Where is the output of TextWriterTraceListener redirected? To the Console or a text file depending on the parameter passed to the constructor.
    28. How do you debug an ASP.NET Web application? Attach the aspnet_wp.exe process to the DbgClr debugger.
    29. What are three test cases you should go through in unit testing? Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly).
    30. Can you change the value of a variable while debugging a C# application? Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.
    31. Explain the three services model (three-tier application). Presentation (UI), business (logic and underlying code) and data (from storage or other sources).
    32. What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET? SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix, but it’s a .NET layer on top of OLE layer, so not the fastest thing in the world. ODBC.NET is a deprecated layer provided for backward compatibility to ODBC engines.
    33. What’s the role of the DataReader class in ADO.NET connections? It returns a read-only dataset from the data source when the command is executed.
    34. What is the wildcard character in SQL? Let’s say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve ‘La%’.
    35. Explain ACID rule of thumb for transactions. Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions), Consistent (data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t), Isolated (no transaction sees the intermediate results of the current transaction), Durable (the values persist if the data had been committed even if the system crashes right after).
    36. What connections does Microsoft SQL Server support? Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords).
    37. Which one is trusted and which one is untrusted? Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction.
    38. Why would you use untrusted verificaion? Web Services might use it, as well as non-Windows applications.
    39. What does the parameter Initial Catalog define inside Connection String?The database name to connect to.
    40. What’s the data provider name to connect to Access database? Microsoft.Access.
    41. What does Dispose method do with the connection object? Deletes it from the memory.
    42. What is a pre-requisite for connection pooling? Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings.

     

    Dot Net Interview Success Kit


    1. Explain the .NET architecture.
    2. How many languages .NET is supporting now? – When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. The site DotNetLanguages.Net
    3. How is .NET able to support multiple languages? – a language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language.
    4. How ASP .NET different from ASP? – Scripting is separated from the HTML, Code is compiled as a DLL, these DLLs can be executed on the server.
    5. Resource Files: How to use the resource files, how to know which language to use?
    6. What is smart navigation? – The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.
    7. What is view state? – The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on for a single control
    8. Explain the life cycle of an ASP .NET page.
    9. How do you validate the controls in an ASP .NET page? – Using special validation controls that are meant for this. We have Range Validator, Email Validator.
    10. Can the validation be done in the server side? Or this can be done only in the Client side? – Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.
    11. How to manage pagination in a page? – Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.
    12. What is ADO .NET and what is difference between ADO and ADO.NET? – ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch.

    Designers and Editors, Shared Shortcuts


     

    Name Shortcut keys Description
    Activate application menu ALT + SPACEBAR Opens the program menu, allowing the user to manage the state of the application window, for example, move or resize.
    Activate document window menu ALT + HYPHEN Opens the document menu, allowing the user to manage the state of the active document window, for example, move or resize. Available only while in MDI mode from within a document window.
    Activate tool window menu ALT + HYPHEN Opens the tool window menu, allowing the user to move the tool window within the IDE. Available only while within a tool window.
    Close application ALT + F4 Closes the IDE.
    Close document CTRL+F6 Closes the active application document.
    Collapse all tree nodes NUM + – Collapses all nodes in the current tree view.
    Expand all tree nodes NUM + * Expands all nodes in the current tree view.
    Move to menu bar ALT Activates the main IDE menu bar.
    Move to next toolbar CTRL + TAB Moves to the next visible toolbar. Available only while the main menu bar is active.
    Move to previous toolbar CTRL + SHIFT + TAB Moves to the previous visible toolbar. Available only while the main menu bar is active.
    Move to tool window toolbar SHIFT + ALT Activates the tool window toolbar. Available only while in a tool window containing a toolbar.
    Move tree focus down CTRL + DOWN ARROW Moves the focus in tree view down without changing the selection. This shortcut can be used to select multiple items in the tree.
    Move tree focus up CTRL + UP ARROW Moves the focus in tree view up without changing the selection. This shortcut can be used to select multiple items in the tree.
    Shortcut menu SHIFT + F10 Displays the shortcut menu.
    Toggle drop-down list visibility F4 Hides and shows a drop-down list. Available only while within a drop-down list.
    Toggle tree focus selection CTRL + SPACEBAR Toggles a selection for the current focus in tree view.

     

    Text To Speech Conversion – convert text to voice


    Imports SpeechLib
    
    Public Class Form1
        Dim voice As New SpVoice
    
        Private Subbtn_Read_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            Try
                voice.Speak(Me.TextBox1.Text)
            Catch ex As Exception
             End Try
        End Sub
    
        Private Sub btn_Read_From_File_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
            Me.OpenFileDialog1.ShowDialog()
            Try
                Dim fs As New System.IO.FileStream(Me.OpenFileDialog1.FileName, IO.FileMode.Open, IO.FileAccess.Read)
                Dim fr As New System.IO.StreamReader(fs)
    
                Me.TextBox1.Text = fr.ReadToEnd
            Catch ex As Exception
            End Try
        End Sub
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.TextBox1.Select()
        End Sub
       
        End Class
    
    ************============***********
    Another Processes 
    
    
    private void btnListen_Click(object sender, EventArgs e)
    {
    	// Speech Recognition Object
    	SpSharedRecoContext listener;
    
    	// Grammar object
    	ISpeechRecoGrammar grammar;
    
    	listener = new SpeechLib.SpSharedRecoContext();
    	listener.Recognition += new _ISpeechRecoContextEvents_RecognitionEventHandler (listener_Reco);
    	grammar = listener.CreateGrammar(0);
    	grammar.Dictationload("", SpeechLoadOption.SLOStatic);
    	grammar.DictationSetState(SpeechRuleState.SGDSActive);
    }
    
    public void listener_Reco(int StreamNumber, object StreamPosition, SpeechRecognitionType RecognitionType, ISpeechRecoResult Result)
    {
    	string heard = Result.PhraseInfo.GetText(0, -1, true);
    	textBox1.Text += heard;
    }


     

    Converting Docx to PDF


    After long hours of researching on this topic, I came accross Bullzip PDF Creator http://www.bullzip.com/products/pdf/info.php . This product is the best freeware programmable pdf printer that I’ve used so far. The installer of pdf printer includes a .NET assembly (no COM!!) called Bullzip.PdfWriter which gives the possibility to print “silently” to pdf – with no user interaction. (The assembly is visible within the “Add Reference” dialog in Visual Studio in the .NET tab!). When the Print() method of this assembly is invoked on a Word 2007 document, it opens Word automatically, launches the Print command and closes Word within a couple of seconds. The pdf printer can also be configured to iterate through a collection of documents. The best thing about this product is that is very well documented, making it quite easy to set up.

    Here’s a piece of code:

     

    using System;
    using System.IO;
    using System.Linq;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.ComponentModel;
    using System.Configuration;
    using System.ServiceModel;
    using Bullzip.PdfWriter;
    
    namespace DocxGenerator.SL.WCF
    {
      public class PdfMaker
      {    
        internal static byte[] PrintToPdf(string appFolder, string tempDocxFileName)
        {
          try
          {
            string tempFolder = appFolder + @"\temp";
            string tempDocxFilePath = tempFolder + @"\" + tempDocxFileName;
    
            PdfSettings pdfSettings = new PdfSettings();
            pdfSettings.PrinterName = ConfigurationManager.AppSettings["PdfPrinter"];
    
            string settingsFile = pdfSettings.GetSettingsFilePath(PdfSettingsFileType.Settings);
            pdfSettings.LoadSettings(appFolder + @"\App_Data\printerSettings.ini");
            pdfSettings.SetValue("Output", tempFolder + @"\<docname>.pdf");
            pdfSettings.WriteSettings(settingsFile);
    
            PdfUtil.PrintFile(tempDocxFilePath, pdfSettings.PrinterName);
            string tempPdfFilePath = tempFolder + @"\Microsoft Word - " + tempDocxFileName + ".pdf";
    
            bool fileCreated = false;
            while (!fileCreated) 
            {
              fileCreated = PdfUtil.WaitForFile(tempPdfFilePath, 1000);
            }
    
            byte[] pdfBytes = File.ReadAllBytes(tempPdfFilePath);
    
            File.Delete(tempDocxFilePath);
            File.Delete(tempPdfFilePath);
    
            return pdfBytes;        
          }
          catch (Exception ex)
          {
            throw new FaultException("WCF error!\r\n" + ex.Message);
          }
        }
      }
    
    }

     

    How To Play Flash Video Files In ASP.NET using C#.net or VB.net


    Videos are becoming common part of web sites today. Before just a few years, web designers avoided even larger picture on site, because Internet connection of many visitors was slow, and movies usually have much more bytes than pictures. Visitors did not like to wait more than a few seconds to see page loaded. Rare videos was very short, had low resolution and bad quality. But now, circumstances are changed. Now almost everyone have fast connection and time of dial-up connection is past. Now you can display video whenever you want to better describe your product or service.

     

    There is a few different ways to show video on web page. Most popular are Windows Media Player, Quick Time, Adobe Flash or Silverlight. If you want to find out how to show video with Windows Media Player you can read How to build ASP.NET Media Player Control tutorial. This tutorial will focus on using of Flash to show flash video files on ASP.NET web site.

    Flash becomes widely used and today it is most used technology for showing movies on Internet. Flash is used by most popular video sharing web sites like YouTube or Google Video. It is compatible with almost every operating system and web browser and very prevalent on Internet users computers. To see Flash movies, users need to have Flash player installed. On my experiences, at least 95% visitors have Flash player installed which is more than other available technologies. Flash is client side technology, although it can be used with static HTML page, but it is usually manipulated by server side web application.

    You can’t show flash video files directly. Flash is just a programming framework, which uses Action Script programming language. You need a program made in Flash (video player) to show .flv video on page. You can of course learn Action Script and develop your own player, but that is out of scope of this tutorial. I will leave that task to Flash developers. Fortunately, there are already some free and very good Flash video players available. Using of them will short your development cycle and provide you a quality solution. I selected JW FLV Player as the best solution.

    Using of JW FLV Player on web page

    There are a two basic steps when placing Flash application to web page:

    – First, declare and initiate a Flash object

    – Second, set properties of object according to your needs.

    You can do this on two different ways, with static HTML tags <OBJECT > and , or by using a JavaScript. With static HTML your code could look something like this:

    <object width=”640″ height=”480″>
    <param name=”movie” value=”player.swf” />

    </object>

     

    We need both <object > and tags to get browser compatibility. Internet Explorer uses <object> tag, but Firefox and Netscape can’t see it and recognize just . We set parameters by using <param > tags, and inside tag. Code example above have added parameter name “movie” and value “player.swf”. You can add any other parameter on the same way. Complete list of supported parameters for JW FLV Player you can see at their Flash vars page.

    http://cdn5.tribalfusion.com/media/2481846/template_300x250_v8.swf

    There is a problem with static HTML if visitors access with Internet Explorer. Flash application would not start until visitor clicks on it. If you just place a cursor over a movie you’ll see an ugly border. Common way to avoid need to click every time when page load is to initiate Flash player with JavaScript. JavaScript code for starting Flash movie could look like this:

    <p id=’preview’>The player will show in this paragraph</p>

    <script type=’text/javascript’ src=’swfobject.js’></script>
    <script type=’text/javascript’>
    var s1 = new SWFObject(‘player.swf’,’player’,’400′,’300′,’9′);
    s1.addParam(‘allowfullscreen’,’true’);
    s1.addParam(‘allowscriptaccess’,’always’);
    s1.addParam(‘flashvars’,’file=video.flv’);
    s1.write(‘preview’);
    </script>

     

    As you can see, nothing complicated here. Code creates SWFObject dynamically and then set its parameters. In this case visitor is not required to click to start a movie. Of course, JavaScript must be enabled in visitor’s web browser.

    Manipulating Flash Player with ASP.NET

    Basically, playing video files with JW FLV Player is simple, you just create an object and set needed parameters as in two code examples above. But, if you work with large number of video files or you need to enable to your users to add their movies you need to automate things. Writing static HTML code for every video certainly not sounds professional. Fortunately, with a little ASP.NET code we can make this task much easier :).

    Creating a custom ASP.NET Flash Player Control

    Basic idea is this: Custom ASP.NET control will have properties related to JW FLV Player parameters. In run time, control will render appropriate content on client side so JW FLV player will show video correctly, and you can manipulate flash videos with ASP.NET web application. Now, we can create admin ASP.NET pages, load videos from database, enable database search etc., without hard coding.

    I created ASP.NET JW FLV Flash Video Player Control that do this task. Control is free and you can use it to show Flash video files on your web site. Source code of control is also available in C# andVB.NET. Example web project is included in download to see how it works.


    Image 1: ASP.NET Flash player control at run time

    You can download this control compiled for ASP.NET 1.1ASP.NET 2.0 and ASP.NET 3.5. Every download contains example web application with sample video files, so you can immediately see how it works.

    Flash Player Control Code Analysis

    As you can see from C# and VB.NET code listings, control code consists from three parts:

    1. Declaring of properties default values on the beginning. For server control, I used same default values like JW FLV Flash player already uses. I added two additional properties to describe location of JW FLV .swf and .js file, like in code bellow.

    [ C# ]

    #region Properties defaults
    const string DefaultSwfobject_jsLocation = “”; // in the same directory
    const string DefaultFlashPlayerLocation = “”; // in the same directory
    const bool DefaultAllowFullScreen = true;
    const string DefaultFile = “”;
    const bool DefaultAutoStart = false;
    const int DefaultBufferLength = 1;

    #endregion

    [ VB.NET ]

    #Region “Properties defaults”
    Const DefaultSwfobject_jsLocation As String = “” ‘ in the same directory
    Const DefaultFlashPlayerLocation As String = “” ‘ in the same directory
    Const DefaultAllowFullScreen As Boolean = True
    Const DefaultFile As String = “”
    Const DefaultAutoStart As Boolean = False
    Const DefaultBufferLength As Integer = 1

    #End Region

     

    2. Value of every property is saved to ViewState if value is different from default value. For example, code for AllowFullScreen property looks like this:

    [ C# ]

    [Bindable(true), Category(“Settings”)]
    bool AllowFullScreen
    {
    get
    {
    if(ViewState[“AllowFullScreen”] == null)
    return DefaultAllowFullScreen;
    else
    return (bool)ViewState[“AllowFullScreen”];
    }
    set
    {
    if(value != DefaultAllowFullScreen)
    ViewState[“AllowFullScreen”] = value;
    else
    ViewState[“AllowFullScreen”] = null;
    }
    }

    [ VB.NET ]

    <Bindable(True), Category(“Settings”)> _
    Property AllowFullScreen() As Boolean
    Get
    If ViewState(“AllowFullScreen”) Is Nothing Then
    Return DefaultAllowFullScreen
    Else
    Return ViewState(“AllowFullScreen”)
    End If
    End Get
    Set(ByVal value As Boolean)
    If value <> DefaultAllowFullScreen Then
    ViewState(“AllowFullScreen”) = value
    Else
    ViewState(“AllowFullScreen”) = Nothing
    End If
    End Set
    End Property

     

    3. RenderContents function produces output to, depended of values of every property, correctly initialize Flash player on client side by using a JavaScript, like mentioned before.

    Conclusion

    With custom ASP.NET Flash Player control that manipulate client side flash player you can save a lot of time. I tested control in Firefox and Internet Explorer and worked fine. Please let me know if you find some bug or you have a suggestion for improvement.

    Going professional with ASPNetFlashVideo

    Control introduced in this tutorial is useful in some simpler scenarios, but keep in mind that JW FLV Player is free only for noncommercial projects. Fortunately, there is pure ASP.NET control namedASPNetFlashVideo that allows you to effortlessly incorporate beautiful Adobe Flash Video (FLV) media into ASP.NET website. For $49 you can use it on single site or just $99 for use on unlimited number of web sites. Except common interface commands for playing flash video files, ASPNetFlashVideosupports skins, custom user interface, play lists, integration with Visual Studio, search engine optimization and more. Things like no ongoing subscription costs, free future updates or 30 days money back guarantee justify decision to give it a try.

     

    Simple Gallery – An Easy Image Gallery for ASP.NET


    This article addresses the construction of a simple image gallery type of web application. This is not the be all, end all solution for web image galleries, but if you want to share a few photos or put together a site to display a small catalog of images, it is a very simple way to get there. In fact, it is so simple; the whole shooting match is entirely managed within the page load event of a single web form.

    Figure 1: Image Gallery Web Application in Use

    Getting Started

    Unzip the solution included with this download, and store it in your file system. After saving the solution, create a virtual directory pointing to that solution using the IIS management console. Next, open the solution up in Visual Studio 2005. In the Solution Explorer, you will note the following:

    Figure 2: Solution Explorer showing the Image Gallery Project

    As you can see, there is not a whole lot to it. There is a single web form called Default.aspx and an added folder (Images) which contains a set of seven JPG image files. All of the action associated with this project occurs in the single code-behind file associated with the Default.aspx page.

    Incidentally, all of the photographs are of the USS Isherwood (DD-520) which was the ship my father served on during World War II. The photograph entitled �DD520_1.jpg� was taken on April 16, 1945 during the Okinawa invasion; six days later, the Isherwood was attacked by a Kamikaze in a raid that killed or wounded 80 of the sailors onboard (including my father).

    Default.aspx Form Layout

    The form layout for this example is pretty simple, the web form uses absolute positioning and it contains two objects. One is a Panel control (pnlThumbs) that is set to scroll vertically and which has a fixed width and height (500 x 170px). The other control is an Image control (imgMain) with its height and width properties left unset. With the image�s height and width properties unset, whenever a new image is loaded into the control, the width and height will be set to display the image without any distortion.

    The Code: Default.aspx

    As advertised, there is only one bit of code to look at in this project, and that is the page load event handler. There are a few imports made at the start of the class, those imports include:

    Collapse
    Imports System.IO
    Imports System.Drawing
    Imports System.Drawing.Bitmap
    Imports System.Drawing.Drawing2D

    These imports are necessary, and are used to work with the image files. Now, take a look at the page load event handler; that bit of code is as follows:

    Collapse
    Protected Sub Page_Load(ByVal sender As Object, _
              ByVal e As System.EventArgs) Handles Me.Load
    
        Me.Title = "USS Isherwood DD-520"
    
        'retrieve selected files of a folder
    
        Dim files() As String
        Dim i As Integer
        files = Directory.GetFiles(Server.MapPath("~\Images"), "*.jpg")
    
        If Page.IsPostBack Then
            Me.imgMain.ImageUrl = Request.QueryString("Img")
        End If
    
        Dim arrIbs(files.Length) As ImageButton
        For i = 0 To files.Length - 1
            Dim image As New Bitmap(files(i).ToString)
            arrIbs(i) = New ImageButton()
            arrIbs(i).ImageUrl = files(i).ToString()
            arrIbs(i).Width = 160
            arrIbs(i).Height = 100
            arrIbs(i).BorderStyle = BorderStyle.Inset
            arrIbs(i).BorderWidth = 2
            arrIbs(i).AlternateText = _
                System.IO.Path.GetFileName(files(i).ToString())
            arrIbs(i).PostBackUrl = "default.aspx?Img=" & _
                                    files(i).ToString()
            Me.pnlThumbs.Controls.Add(arrIbs(i))
            Dim lbl As New Label
            lbl.Text = "<br/>"
            pnlThumbs.Controls.Add(lbl)
        Next
    
    End Sub

    The first line of the handler merely sets the title of the page.

    Collapse
    Me.Title = "USS Isherwood DD-520"

    Following that, the next bit of code declares a String array (files) used to contain the paths to the image files contained in the Images folder. The files collected are limited to JPG files; naturally, this could include other file types.

    Collapse
    'retrieve selected files of a folder
    
    Dim files() As String
    Dim i As Integer
    files = Directory.GetFiles(Server.MapPath("~\Images"), "*.jpg")

    After the files are identified, the event handler will check for a post back and, if the page is a post back, use the query string value entitled �Img� to get the path to the last selected file and set the form�s main image to display that image by setting the ImageUrl property of the control to point to the path of the last selected image file.

    Collapse
    If Page.IsPostBack Then
        Me.imgMain.ImageUrl = Request.QueryString("Img")
    End If

    The event handler will wrap up by creating the image gallery:

    Collapse
    Dim arrIbs(files.Length) As ImageButton
    For i = 0 To files.Length - 1
        arrIbs(i) = New ImageButton()
        arrIbs(i).ImageUrl = files(i).ToString()
        arrIbs(i).Width = 160
        arrIbs(i).Height = 100
        arrIbs(i).BorderStyle = BorderStyle.Inset
        arrIbs(i).BorderWidth = 2
        arrIbs(i).AlternateText = System.IO.Path.GetFileName(files(i).ToString())
        arrIbs(i).PostBackUrl = "default.aspx?Img=" & files(i).ToString()
        Me.pnlThumbs.Controls.Add(arrIbs(i))
        Dim lbl As New Label
        lbl.Text = "<br/>"
        pnlThumbs.Controls.Add(lbl)
    Next

    To create the gallery, the handler creates an array of ImageButton controls, with the size of the array set to equal the number of files in the filesarray. Next, the code will loop through the array of files and declare and capture an image from the current file, and in each pass, instance the image control from the array of image buttons, and set the ImageUrl property to point to the current image file. The height and width of the image control are set to make all of the images the same size (and depending upon the images you are dealing with, you may want to set the height and width to some other values). In this instance, I merely set the size of the image to be on half of the size of a 320 x 200 pixel image.

    After the image URL is set, the image is given an inset border with a width of 2px. The AlternateText property of the current image button is set to display the name of the file without the full path information included. Next, the PostBackUrl property is set to recall the current page and pass the query string containing the path to the last selected image file. This control is then added to the control collection of the panel.

    The Label control is added as a spacer between the small version of the image, and it is added as well to the Panel after it has been declared and populated.

    That is all there is to it; when the page is displayed, whenever the user selects an image button from the gallery, the page does a post back and the query string value is used to load the selected image into the main image.

     

    File uploader in C#


    This is very basic level small user control, in which we can discuss how to create web user control.

    To create user controls follow the steps:

    1. Right click on project
    2. Click on Add
    3. Select New Item
    4. Select Web User Control
    5. Specify some Name

    I have given name to this file as “uploader.ascx” and kept this file under “userControl” for simplicity purpose.

    On this page I am having following controls:

    1. <INPUT id=”fileUpload” type=”file” Runat=”server” NAME=”fileUpload”>
    2. <asp:label id=”lblMessage” runat=”server” Width=”416px” Font-Size=”10″ Font-Name=”verdana”></asp:label>
    3. <asp:button id=”btnSave” runat=”server” Text=”Upload..”></asp:button>

    At the code behind of above file I am having following function

    public string uploadFile(string fileName,string folderName)

    {

    if(fileName==””)

    {

    return “Invalid filename supplied”;

    }

    if(fileUpload.PostedFile.ContentLength==0)

    {

    return “Invalid file content”;

    }

    fileName = System.IO.Path.GetFileName(fileName);

    if(folderName==””)

    {

    return “Path not found”;

    }

    try

    {

    if (fileUpload.PostedFile.ContentLength<=2048000)

    {

    fileUpload.PostedFile.SaveAs(Server.MapPath(folderName)+”\\”+fileName);

    return “File uploaded successfully”;

    }

    else

    {

    return “Unable to upload,file exceeds maximum limit”;

    }

    }

    catch(UnauthorizedAccessException ex)

    {

    return ex.Message + “Permission to upload file denied”;

    }

    }

     

    The above function takes care of following things before uploading file to the folder

    1. Invalid file name supplied.
    2. If file not exists or content length 0.
    3. Folder name exists.

    Error Handling

    While uploading done with UnauthorizedAccessException and returned with the message

    On upload button click I am having following code

     

    private void btnSave_Click(object sender, System.EventArgs e)

    {

    string strFilename, strMessage;

    strFilename = fileUpload.PostedFile.FileName.ToString();

    strMessage = uploadFile(strFilename,ConfigurationSettings.AppSettings[“folderPath”]);

    lblMessage.Text = strMessage;

    lblMessage.ForeColor = Color.Red;

    }

     

    I have made use of Web.config file, in which I have added attribute as follows under:

     

    <configuration>
    <appSettings>
    <add key=”folderPath” value=”Images”></add>
    </appSettings>

    i.e. I have set up path of folder to upload image

    To access control in project, I have added page called as “uploadTester.aspx” to the project in which I have added following line:

    <%@ Register TagPrefix=”img” TagName=”Uploader” src=”userControl/uploader.ascx”%>

    Which says that this control is register to this page with specified source.

    And in HTML code I have added following code inside form tag:

    <img:Uploader runat=”server” id=”Uploader1″></img:Uploader>

    That’s all about

    General:

    To upload any of the file in respective folder user need to have permission for writing to the folder so please follow the following steps to prevent from the error.

    Set permission to virtual directory by following steps in IIS

    • Right Click on virtual directory which you have created for this project. Under directory Tab you will find
      1)Read
      2)Log Visits
      3)Index this resources
      Are marked as checked (enables) in addition to this make
      4)Write access enabled or checked
    • Click on apply
    • Click on ok

    This will set right permission to entire virtual directory, this way we can minimize error from the front end for permission / access denied.

    Other way to solve permission denied issue is to go to actual folder “images” by using physical path and follow these steps:

    • Right click folder
    • Sharing Tab
    • Enable share this folder radio button
    • Click Apply
    • Click Ok

    If u are using this code on 2000 server you should do following:

    • Right click respective folder
    • Go to security tab
    • Select Everyone user
    • Apply full control
    • click on ok

    Kindly go through zip file for entire code.

     

     


    Introduction

    I noticed that there are several articles on using Web Setup projects, but no articles could be found for Windows Setup projects. So I decided to share what I know about the VS Windows Setup Projects. I will be using the RunOnlyOnceCS.exe demo app I created for another CodeProject article, as the application we are creating the setup for.

    Background

    Sooner or later, you need to create a setup project for an application. Personally, I am not a big fan of this type of distribution for an application. Still it has its uses. Using a setup project can be a good solution for a Windows application that has many dependencies on other assemblies / DLLs. The setup will figure out what the dependencies are for the application and automatically include them. Note: This does not include the .NET framework.

    Creating a Setup Project

    This article is going to rely on screen prints since there really isn�t any code for this. The output will be a *.msi file that will install the applicationfile(s), and add a shortcut to the desktop and to the Programs menu. Note: if the user does not have admin rights to their box, they will not be able to run the MSI script or install new applications on their box. After you have created a new setup project, the first thing you will want to do is change the ProductName property on the setup project to match the application you are creating the setup for. I would also suggest changing the RemovePreviousVersion property to true. This is helpful when you want to release your next version of your app through this setup project. Next, click on the “Application folder”, then right click, and click on Add/File. At this point, you will be able to add the Exe you are trying to create thesetup for. Note: if you make changes to the Exe, you will need to re-compile the setup project as well. It might be a good choice to add a setup project to yourWindows project solution. Then you can choose the project output option instead of the file. Note: if you know what a merge module is and want to add one to the setup project, you need to right click on the setup project and click Add Merge Module. Note: you must also add any config or icon files you may need for this solution, here: Next, I always set the Always Create for the Program Directory to true. This is done by clicking on the “Application Folder” and then going to the properties. Note: the DefaultLocation property will always be: [ProgramFilesFolder] [Manufacturer]\[ProductName]. If you want it to be something else, this is where to change it. Notice that the solution explorer has recognized the dependency or need for the .NET Framework for this app to run. Note: this does not mean that the setup will install the .NET re-distributable framework. That is its own setup. The setup file is around 24 MB in size and can be downloaded from here. Note: the setup can not install a .NET application without the .NET Framework already installed. Next, we want to create a shortcut to our application on the desktop. First, click on the “User’s desktop” folder. Then right click and click on “Create New Shortcut”. Next, you will see a dialog box to choose the application you want to create a shortcut to. Go to “Application folder” and add the exe you added in the previous step. If you click on the “User’s desktop” and go to the Properties window, you will see some options. Something I normally add to the shortcut is a check to see if it already exists. This is an example of what little coding you can do in a setup project. I have turned on AlwaysCreate on the shortcut property. In doing this, I need to have a condition or I will multiply my desktop shortcuts with every new release. So I set the Transitive property to True and I set the condition to FILEEXISTS1<>”Shortcut to RunOnceOnlyCS.exe, where what is in the “” needs to match the name of the shortcut. Note: if you want your shortcut to have your application’s icon, you need to add your icon file to the “Application folder”. Next, click on the shortcut you just created in your “User’s desktop”. There is an icon property. Click the down arrow to get the dialog box. Navigate to the “Application folder” and select the icon file you just added. Next, if you want to create a shortcut in the Start/All Programs menu, it is very similar to creating a shortcut on the “User’s desktop”. First, click on the “User’s programs menu”, then right click and add a folder. Name the folder the same as whatever your company or manufacturer name would be. Then, click on that newly created folder and add a shortcut just like we did in the step above. Finally, when you need to create a new setup for the next release of your application, you need to go to the setup project properties and change the version before you re-compile the setup project. Once you click off the version property, you will get a prompt to update the GUID for the ProductCode. Note: if you do not click the Yes button in the dialog, you must manually get a new GUID for the ProductCode for the setup to properly remove the old program and install the new program. ===============********************======================

     

    Another Process:

    Visual Studio 2005 Setup and deployment Projects provides to make an exe or installer file in .NET windows application is easy and rapidly.

    Visual Studio provides templates for four types of deployment projects: Merge Module Project, Setup Project, Web Setup Project, and Cab Project. In addition, a Setup wizard is provided to help step you through the process of creating deployment projects. You can see the templates and the wizard in the New Project dialog box under the Setup and Deployment Projectsnode.

    The following are guidelines for choosing the right type of deployment project for your project.

    1)Merge Module Project : Packages components that might be shared by multiple applications.

    2)Setup Project : Builds an installer for a Windows-based application.

    3)Web Setup Project : Builds an installer for a Web application.

    4)Cab Project : Creates a cabinet file for downloading to a legacy Web browser.

    5)Smart Device Cab Project : Creates a Cab project to deploy device applications.

    This topic demonstrates deployment using a Setup and Deployment Project.

    Setup Projects

    Setup projects allow you to create installers in order to distribute an application. The resulting Windows Installer (.msi) file contains the application, any dependent files, information about the application such as registry entries, and instructions for installation. When the .msi file is distributed and run on another computer, you can be assured that everything necessary for installation is included; if for any reason the installation fails (for example, the target computer does not have the required operating system version), the installation will be rolled back and the computer returned to its pre-installation state.

    The following steps will gives the elegant guidance to create an exe or installer file.

    1, Go to file menu > click Add > new project >now “Add New Project” dialog will appear.

    2.Select the “Other Project Types” and click “Setup and Deployment” projects,Choose “Setup Project”give name project name in name text box finally click OK.

    3.New project appear in solution explorer,for eg., you have give the name “MyEXE” file will be displays with given name.

    4.Right click the MyEXE > go View > click “File System”

    5.You can see the “File System on TargetMachine”under  three folders
    Application Folder
    User’s Desktop
    User’s Program Menu

    6.Select Application Folder and right click Add>Project Output>select Primary output

    7. Select User’s Desktop richt click on the second window>click create new shortcut>select output file from Application folder>change the file name from  primary output name to MyEXE

    next >>

    same procedure follows the user’s program menu also

    8.If you want to change the Manufactures name for exe,just right click the project go to properties

    change the properties as per you requirement

    9.Finally Build the new project After successfully Build the project myEXE(Setup) will be appear in Application Debug or Release folder(depend upon the properties settings)

    EXE or installer will be available on his physical path…

     

    Building A Web Service In ASP.NET 3.5


    The steps to build a web service in ASP.NET 3.5 haven’t changed much from previous versions but there are few new things to keep in mind. The biggest new feature in ASP.NET 3.5 are the “AJAX-enabled” web services. You can now set up your web service to return in either the standard SOAP/XML format or “AJAX-enable” your service with a single setting that will allow you to call your Web Service methods directly in javascript in your ASPX pages.

    Building a Simple Web Service

    To create a web service, first add a new .ASMX file to your web project by right-clicking your web project and selectingAdd New Item.

    Choose Web Service from the horribly unsorted list (Why can’t we get this alphabetized!!!). Then choose a name for your service. I recommend selecting “Place code in separate file”. This setting will create a “ExampleWebService.asmx” file at the project root or where ever you are currently adding this service and will put the actualy C# code for the services in your App_Code directory as a file called “ExampleWebService.asmx.cs”. Then click Add.

    visual studio add new item - web service

    Your new service should look something like this:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    
    /// <summary>
    /// Summary description for ExampleWebService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    
    // [System.Web.Script.Services.ScriptService]
    public class ExampleWebService : System.Web.Services.WebService
    {
        public ExampleWebService()
        {
            //Uncomment the following line if using designed components 
            //InitializeComponent(); 
        }
    
        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }
    }

    Setting up the Web Service code

    The first thing you need to do is change your URI namespace. By default, it is set to http://tempuri.org/. But you want this to a completely unique URI string to you and/or your organization. It does not have to be a valid URL to an actual page (although that’s a good idea if you want to publish a user guide or usage policy there). I normally just use the URL to where this web service will reside in production. For instance, I might put:http://www.devtoolshed.com/webservices/examplewebservice/. NOTE: It’s always good to add the final “/” to end of your URL if it is to a directory path to make it a well-formed URL.

    The next thing to notice here is the section just below that says “To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.” If you uncomment this line, it will “AJAX-enable” your service so that you can call it using the ASP.NET AJAX framework and javascript. Very useful. But if you aren’t using this feature, just leave it commented out.

    It’s kind of lame but Microsoft puts a sample “HelloWorld” web method already in there so you can see the format (I guess it’s tradition because this has been in there since ASP.NET 1.0). For a simple service that just returns a base data type such as int or string, this HelloWorld method is a good example.

    Notice in the HelloWorld method, the way that you enable this method to be called remotely is by using the “[WebMethod]” attribute above the method signature. When WebMethod is placed above a public function in this web service class, ASP.NET does ALL the work for you. This really is the best part. It will automatically add your method to the WSDL definition of the service. It will wrap your return values as well as parameters in SOAP for you. You literally just code this like a normal method and all the SOAP and security layer work is done automatically for you.

    NOTE: You can add as many [WebMethod]’s as you like to your web service class and they will all be available as remotely executable functions for your clients invokers.

    [WebMethod] Description parameter

    There is an extra parameter that is available for the [WebMethod] attribute that I like to add called Description. This allows you to describe the web method. Just for fun, I’ve added a parameter to the HelloWorld service as well to pass a message to the string.

    Here’s an example using the Description parameter for the HelloWorld method:

    [WebMethod(Description = "Says hello to the world!")]
    public string HelloWorld(string sMessage)
    {
        return "Hello World" + sMessage;
    }

    Running the Web Service

    Now you can run this web service by right-clicking the ExampleWebService.asmx file and choosing “Set as start page” and hitting F5. ASP.NET automatically generates a run-time wrapper for your services so you can test, step into code, and make sure you have them all coded correctly before going live. You should see a page something like this:

    web service list of operations

    If you click on the HelloWorld method link, you can actually run the service. ASP.NET will even create a simple web form that you can enter the parameter values for your method to invoke it. Type a message and then click “Invoke”.

    invoke a web service method

    You should have an XML return value that looks something like this:

    <?xml version="1.0" encoding="utf-8"?>
    <string xmlns="http://www.devtoolshed.com/webservices/examplewebservice/">Hello World you look wonderful!</string>

    NOTE: The SOAP wrapper is not shown here to keep things simple when developing but it will be added automatically when this service is invoked via a SOAP enabled client.

    Web Services that return Complex Types

    For simple web services (not very common), this works great. But what if you want to actually pass a complex type such as an object your created as the return value or even accept one as a parameter to your method? Luckily, this is also supported out of the box.

    Here are a few things to keep in mind when doing this:

    • If you pass a complex type as a parameter, then ASP.NET will not be able to generate the run-time web page wrapper we just used. It won’t know how to translate your custom object to a base data type. So to test your methods, you will need to use a simple client application to call your web services so you can step into code, etc.
    • HIGHLY RECOMMEND that when you return complex types as return values, you do NOT use your direct data access layer objects. There are a couple of reasons for this. 1) Web services, once in production and being used, become one of your most brittle interfaces. If you decide to change your database object down the road, then as soon as you do, it will ripple effect through your services and break every interface. 2) Once your service is being called by client applications, they would all need to be updated each time you made a change to your data access layer objects.
    • NEVER return Strongly Typed DataSets as return values! There is a known limitation in ASP.NET which limits you to 1 method per web service class that can return a DataSet. This has to do with the fact that DataSets are actually stored as XML and the service itself is XML so there are conflicts. I ran into this issue a while back and it took a long time to figure out. The only work around we could ever find was to create a separate web service class for each method that returned a strongly typed DataSet. We had 10’s of web service objects and it was a nightmare to manage.

    What I’ve found that works great is to isolate your interfaces for your web services into a namespace. I usually call this namespace something like “WebServiceTypes”. I recommend putting every object type that is returned as a value and is passed as a parameter to your web services here. Here’s an example of how to do this:

    Complex Type Example

    First, create a new directory in your App_Code directory called “WebServiceTypes”. Let’s change HelloWorld to return a complex type.

    Add new Class to the WebServiceTypes directory called “ExampleComplexType”. Here’s some code to make it a complex type:

    namespace WebServiceTypes
    {
        /// <summary>
        /// An example of a complex type to be used as a return value in a web service.
        /// </summary>
        public class ExampleComplexType
        {
            public ExampleComplexType()
            {
                // constructor
            }
    
            // unique id of the message
            public int MessageId { get; set; }
            // message to say hello
            public string HelloMessage { get; set; }
            // message to say world
            public string WorldMessage { get; set; }
        }
    }

    Modified HelloWorld Method

    Here is the HelloWorld method changed to return ExampleComplexType as the return value:

    [WebMethod(Description = "Says hello to the world!")]
    public WebServiceTypes.ExampleComplexType HelloWorld(string sMessage)
    {
        // create new complex type object to be returned
        WebServiceTypes.ExampleComplexType complexType = new WebServiceTypes.ExampleComplexType
    
    ();
    
        // fill object with values to return.
        // NOTE: here you could do a database query or file system read
        // to get the values to build up you complex type properties.
        complexType.MessageId = 1234;
        complexType.HelloMessage = "Hello";
        complexType.WorldMessage = "World " + sMessage;
    
        // return the complex type
        return complexType;
    }

    Now run the web service again and the XML returned should look like this:

    <?xml version="1.0" encoding="utf-8"?>
    <ExampleComplexType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.devtoolshed.com/webservices/examplewebservice/">
      <MessageId>1234</MessageId>
      <HelloMessage>Hello</HelloMessage>
      <WorldMessage>World is so wonderful!</WorldMessage>
    </ExampleComplexType>

    The nice thing about doing a WebServiceTypes namespace is that you are translating your objects for the web service calls so even if your data access classes or any other objects change, your web services will still work and you won’t break your client callers.

     

    How to Create Shortcut of Application programatically using C#


    There are some situations in which we need to code to create a short cut of ourapplication especially when user loose the shortcuts created by the application after the setup has been run because some shortcuts also have defines special parameters that are for  executable that runs program.

    So here is article i am presenting that will show you how to write code in c# that will create shortcut programmatically.

    Step 1:

    Create a New Windows Form Project.

    Step 2:

    Drag drop a button control from Toolbox to Form name it btnShortcut and Set text Property to “Create Shortcut “

    Step 3:

    For creating shortcut you need to reference Windows Script Host Object so follow the steps as below

    Step 4:

    Add namespace as below

    using IWshRuntimeLibrary;

    Step 5:

    Now write code in Button’s Click event like below

    private void btnShortcut_Click(object sender, EventArgs e)

    {

    WshShellClass shell = new WshShellClass();

    IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(@”D:\shotcut.lnk”);

    shortcut.TargetPath = Application.ExecutablePath;

    //shortcut.IconLocation = ‘Location of  iCon you want to set”;

    // add Description of Short cut

    shortcut.Description = “Any Description here “;

    // save it / create

    shortcut.Save();

    }

     

     

     

    There are some situations in which we need to code to create a short cut of our application especially when user loose the shortcuts created by the application after the setup has been run because some shortcuts also have defines special parameters that are for  executable that runs program.

    So here is article i am presenting that will show you how to write code in c# that will create shortcut programmatically.

    Step 1:

    Create a New Windows Form Project.

    Step 2:

    Drag drop a button control from Toolbox to Form name it btnShortcut and Set text Property to “Create Shortcut ”

    8-6-2010 6-47-21 PM.gif

    Step 3:

    For creating shortcut you need to reference Windows Script Host Object so follow the steps as below

    Step 3a:

    8-6-2010 6-36-00 PM.gif

    Step 3b:

     

    8-6-2010 6-39-47 PM.gif

    Step 4:

    Add namespace as below

    using IWshRuntimeLibrary;

     

    Step 5:

    Now write code in Button’s Click event like below

    private void btnShortcut_Click(object sender, EventArgs e)

    {

     

    WshShellClass shell = new WshShellClass();

     

    IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(@”D:\shotcut.lnk”);

     

    shortcut.TargetPath = Application.ExecutablePath;

    //shortcut.IconLocation = ‘Location of  iCon you want to set”;

     

    // add Description of Short cut

    shortcut.Description = “Any Description here “;

     

    // save it / create

    shortcut.Save();

     

    }

    Step 6: you are done here is your result

     

    8-6-2010 6-57-23 PM.gif

    GridView with DataPager in ASP.NET 3.5


    To page through data in a control that implements the IPageableItemContainer interface, DataPager control can be used. GridView has its own paging and does not implement IPageableItemContainer interface. ListView is the only control that works with DataPager.

    The DataPager control supports built-in paging user interface (UI). NumericPagerField object enables users to select a page of data by page number. NextPreviousPagerField object enables users to move through pages of data one page at a time, or to jump to the first or last page of data. The size of the pages of data is set by using the PageSize property of the DataPager control. One or more pager field objects can be used in a single DataPager control. Custom paging UI can be created by using the TemplatePagerField object. In the TemplatePagerField template, the DataPager control is referenced by using the Container property which provides access to the properties of the DataPager control. These properties include the starting row index, the page size, and the total number of rows currently bound to the control.

    So let’s begin extending the GridView with the IPageableItemContainer interface.

    Define a new class as below
    /// <summary>

    /// DataPagerGridView is a custom control that implements GrieView and IPageableItemContainer

    /// </summary>

    public class DataPagerGridView : GridView, IPageableItemContainer

    {
    }

    MaximumRows will be equal to the PageSize property
    /// <summary>

    /// IPageableItemContainer’s MaximumRows  = PageSize property

    /// </summary>

    int IPageableItemContainer.MaximumRows

    {

    get { return this.PageSize; }

    }

    StartRowIndex can be calculated from the PageSize and PageIndex properties
    /// <summary>

    /// IPageableItemContainer’s StartRowIndex = PageSize * PageIndex properties

    /// </summary>

    int IPageableItemContainer.StartRowIndex

    {

    get { return this.PageSize * this.PageIndex; }

    }

    The SetPageProperties method is called by the DataPager control every time that the control must update the page-related properties. When implemented by a class, the SetPageProperties method must internally update the MaximumRows and StartRowIndex properties by using the values of the maximumRows and startRowIndex parameters. So set the Grid with appropriate parameters and bind to right chunk of data.
    /// <summary>

    /// Set the control with appropriate parameters and bind to right chunk of data.

    /// </summary>

    /// <param name=”startRowIndex”></param>

    /// <param name=”maximumRows”></param>

    /// <param name=”databind”></param>

    void IPageableItemContainer.SetPageProperties(int startRowIndex, int maximumRows, bool databind)

    {

    int newPageIndex = (startRowIndex / maximumRows);

    this.PageSize = maximumRows;

    if (this.PageIndex != newPageIndex)

    {

    bool isCanceled = false;

    if (databind)

    {

    //  create the event arguments and raise the event

    GridViewPageEventArgs args = new GridViewPageEventArgs(newPageIndex);

    this.OnPageIndexChanging(args);

    isCanceled = args.Cancel;

    newPageIndex = args.NewPageIndex;

    }

    //  if the event wasn’t cancelled change the paging values

    if (!isCanceled)

    {

    this.PageIndex = newPageIndex;

    if (databind)

    this.OnPageIndexChanged(EventArgs.Empty);

    }

    if (databind)

    this.RequiresDataBinding = true;

    }

    }

    For the DataPager to render the correct number of page buttons and enable/disable them, it needs to know the total number of rows and the Page Size. But this information is with the GridView and not known to the DataPager.As the GridView control inherits from CompositeDataboundControl which contains a variant of the CreateChildControls method that also takes in a property indicating whether the control is being bound to data or simply re-rendered. The GridView uses this method to bind to its data source and here we can place a trigger for the TotalRowCountAvailable event to be raised. Call base control’s CreateChildControls method and determine the number of rows in the source then fire off the event with the derived data and then we return the original result.
    protected override int CreateChildControls(IEnumerable dataSource, bool dataBinding)

    {

    int rows = base.CreateChildControls(dataSource, dataBinding);

    //  if the paging feature is enabled, determine the total number of rows in the datasource

    if (this.AllowPaging)

    {

    //  if we are databinding, use the number of rows that were created, otherwise cast the datasource to an Collection and use that as the count

    int totalRowCount = dataBinding ? rows : ((ICollection)dataSource).Count;

    //  raise the row count available event

    IPageableItemContainer pageableItemContainer = this as IPageableItemContainer;

    this.OnTotalRowCountAvailable(newPageEventArgs(pageableItemContainer.StartRowIndex,pageableItemContainer.MaximumRows,totalRowCount));

    //  make sure the top and bottom pager rows are not visible

    if (this.TopPagerRow != null)

    this.TopPagerRow.Visible = false;

    if (this.BottomPagerRow != null)

    this.BottomPagerRow.Visible = false;

    }

    return rows
    }

    That’s all you are done, put the control on aspx page and use DataPager with GridView Contol.

     

    10 reasons why SQL Server 2008 is going to rock


    10.  Plug-in model for SSMS.   SSMS 2005 also had a plug-in model, but it was not published, so the few developers that braved that environment were flying blind.  Apparently for 2008, the plug-in model will be published and a thousand add-ins will bloom.

    9.  Inline variable assignment. I often wondered why, as a language, SQL languishes behind the times.  I mean, it has barely any modern syntactic sugar.  Well, in this version, they are at least scratching the the tip of the iceberg.

    Instead of:

    DECLARE @myVar int
    SET @myVar = 5

    you can do it in one line:

    DECLARE @myVar int = 5

    Sweet.

    8.  C like math syntax.  SET @i += 5.  Enough said.  They finally let a C# developer on the SQL team.

    7.  Auditing. It’s a 10 dollar word for storing changes to your data for later review, debugging or in response to regulatory laws.  It’s a thankless and a mundane task and no one is ever excited by the prospect of writing triggers to handle it.  SQL Server 2008 introduces automatic auditing, so we can now check one thing off our to do list.

    6.  Compression.  You may think that this feature is a waste of time, but it’s not what it sounds like.  The release will offer row-level and page-level compression.  The compression mostly takes place on the metadata.  For instance, page compression will store common data for affected rows in a single place.

    The metadata storage for variable length fields is going to be completely crazy: they are pushing things into bits (instead of bytes).  For instance, length of the varchar will be stored in 3 bits.

    Anyway, I don’t really care about space savings – storage is cheap.  What I do care about is that the feature promised (key word here “promises”) to reduce I/O and RAM utilization, while increasing CPU utilization.  Every single performance problem I ever dealt with had to do with I/O overloading.  Will see how this plays out.  I am skeptical until I see some real world production benchmarks.

    5.  Filtered Indexes. This is another feature that sounds great – will have to see how it plays out.  Anyway, it allows you to create an index while specifying what rows are not to be in the index.  For example, index all rows where Status != null.  Theoretically, it’ll get rid of all the dead weight in the index, allowing for faster queries.

    4.  Resource governor. All I can say is FINALLY.  Sybase has had it since version 12 (that’s last millennium, people).  Basically it allows the DBA to specify how much resources (e.g. CPU/RAM) each user is entitled to.  At the very least, it’ll prevent people, with sparse SQL knowledge from shooting off a query with a Cartesian product and bringing down the box.

    Actually Sybase is still ahead of MS on this feature.  Its ASE server allows you to prioritize one user over another – a feature that I found immensely useful.

    3.  Plan freezing.  This is a solution to my personal pet peeve. Sometimes SQL Server decides to change its plan on you (in response to data changes, etc…).  If you’ve achieved your optimal query plan, now you can stick with it.  Yeah, I know, hints are evil, but there are situations when you want to take a hammer to SQL Server – well, this is the chill pill.

    2.  Processing of delimited strings. This is awesome and I could have used this feature…well, always.  Currently, we pass in delimited strings in the following manner:

    exec sp_MySproc 'murphy,35;galen,31;samuels,27;colton,42'

    Then the stored proc needs to parse the string into a usable form – a mindless task.

    In 2008, Microsoft introduced Table Value Parameters (TVP).

    CREATE TYPE PeepsType AS TABLE (Name varchar(20), Age int)
    DECLARE @myPeeps PeepsType
    INSERT @myPeeps SELECT 'murphy', 35
    INSERT @myPeeps SELECT 'galen', 31
    INSERT @myPeeps SELECT 'samuels', 27
    INSERT @myPeeps SELECT 'colton', 42exec sp_MySproc2 @myPeeps

    And the sproc would look like this:

    CREATE PROCEDURE sp_MySproc2(@myPeeps PeepsType READONLY) ...

    The advantage here is that you can treat the Table Type as a regular table, use it in joins, etc.  Say goodbye to all those string parsing routines.

    1. Intellisense in the SQL Server Management Studio (SSMS).  This has been previously possible in SQL Server 2000 and 2005 with Intellisenseuse of 3rd party add-ins like SQL Prompt ($195).  But these tools are a horrible hack at best (e.g. they hook into the editor window and try to interpret what the application is doing).

    Built-in intellisense is huge – it means new people can easily learn the database schema as they go.

    Creating Shortened URLs


    Introduction

    URL shortening services have been around since at least 2002, which was when TinyURL, the first notable shortening service, was launched. URL shortening services work by taking a long URL as input and generating a shorter URL that, when visited, redirects to the original, longer URL. URL shortening services are useful for sharing long URLs in limited space, such as in a tweet or PowerPoint presentation.

    There are a variety of free, publicly available URL shortening services, including TinyURL, Bit.ly, and Goo.gl (Google’s URL shortener service), among others. All of these services provide a website where you can create and manage shortened URLs from your browser; some also offer an API from which you can programmatically create shortened URLs.

    This article shows how to use Google’s URL Shortener API to create shortened URLs.

    Step 1: An Overview of Google’s URL Shortener API

    The Google URL Shortener API offers programmatic access to goo.gl, which is Google’s URL shortener service. Interfacing with the Google URL Shortener API involves making an HTTP request to https://www.googleapis.com/urlshortener/v1/url and sending along appropriate parameters. For example, to shorten the URLhttp://www.dotnetslackers.com, make a POST request of the following format:

    2.Content-Type: application/json

    The Google URL Shortener API will then respond with the following:

    1.{
    2.kind: "urlshortener#url"
    5.}

    Here, id reports the shortened URL, while longUrl indicates the URL a user will be redirected to when the shortened URL is visited. Note that both the data transmitted to and received from the Google URL shortener service is represented as JSON, which is a lightweight data-exchange format commonly used in Ajaxscenarios.

    NOTEAt the time of writing, the Google URL Shortener API is still in Google Labs, meaning it is not a finalized product. Be aware that its functionality or interface may change or may have changed since this article was authored.

    Step 2: Register an API Key

    You can use the Google URL Shortener API anonymously, as in the example above. However, Google recommends that you authenticate when using the API. This is a simple process:

    Using an API key grants you a higher number of queries to the URL Shortening API per day – currently, 1,000,000 requests per day. Moreover, by making authenticated requests you can track your API usage from your Google account.

    Calling the Google URL Shortener API from ASP.NET

    To generate a short URL from a long one we need to send a properly formatted HTTP request to the Google URL Shortener API. The HttpWebRequest andHttpWebResponse class’s in the .NET Framework’s System.Net namespace contain all of the functionality we need for issuing the request and reading the response.

    The following code starts by creating an HttpWebRequest object and specifying that the request should be a POST and use a Content-Type header of application/json. Next, the JSON payload sent in the POST is crafted and then converted into a byte array so that it can be written to the HttpWebRequest’s request stream:

    01.var req = HttpWebRequest.Create(GetUrl());
    02.req.Method = "POST";
    03.req.ContentType = "application/json";
    04.var postBody = string.Format(@"{{""longUrl"": ""{0}""}}", longUrl);
    05.var postData = Encoding.ASCII.GetBytes(postBody);
    06.req.ContentLength = postData.Length;
    07.var reqStream = req.GetRequestStream();
    08.reqStream.Write(postData, 0, postData.Length);
    09.reqStream.Close();

    We are now ready to transmit the HTTP request and work with the response. The following code does just that. First, we call the HttpWebRequest object’sGetResponse method, which sends the request and creates a HttpWebResponse object from which we can examine the response. The response is read into a string and then ASP.NET’s JavaScriptSerializer class is used to deserialize the JSON payload into a ShortenLongUrlResponse object. (ShortenLongUrlResponse is a class I created that models the data returned by the JSON payload; it has three string properties: kindid, and longUrl.)

    01.var resp
    02.
    03.= req.GetResponse();
    04.using (var respReader = new StreamReader(resp.GetResponseStream()))
    05.{
    06.var responseBody = respReader.ReadToEnd();
    07.var deserializer = new JavaScriptSerializer();
    08.var results = deserializer.Deserialize<ShortenLongUrlResponse>(responseBody);
    09.}

    At this point you can get the shortened URL via the results object’s id property.

    The download for this article includes a class named UrlShortener that has a method named ShortenShorten accepts a string as input – the long URL – and returns a ShortenLongUrlResponse object whose id property specifies the shortened URL. You could use this class to shorten a URL like so:

    1.var shortenedResponse = UrlShortener.Shorten
    2.
    4.string shortenedUrl = shortenedResponse.id;

    Calling the Google URL Shortener API from JavaScript

    As we have seen, generating a shortened URL is as simple as sending a properly-formatted HTTP POST request to https://www.googleapis.com/urlshortener/v1/url, and in ASP.NET this can be accomplished using the HttpWebRequest class. But what if we want to generate a shortened URL from client-side script? Unfortunately, browsers prohibit cross-domain POST requests from script for security reasons, meaning we cannot directly call the Google URL Shortener API from JavaScript. Instead, we’ll need to use a proxy. Rather than calling the Google URL Shortener API directly, our script will have to make a request to a web page on our site, which can then make the call to Google and return the shortened URL.

    The demo available for download includes such a proxy. I created a generic HTTP Handler in the Services folder named Url.ashx. This handler:

    1. Reads in the querystring parameter longUrl,
    2. Sends this value to the Google URL Shortener API, and
    3. Returns the shortened URL as its output.

    For example, visiting www.example.com/Services/Url.ashx?longUrl=http://www.json.org/ returns the response http://goo.gl/O2WH.

    This proxy can then be invoked from JavaScript. The following script shows how to use jQuery’s $.get function to make a request to the proxy and display the returned shortened URL:

    1.var longUrl = "http://www.json.org/";
    2.$.get("Services/Url.ashx?longUrl=" + longUrl, function (shortenedUrl) {
    3.alert("The new, short URL: " + shortenedUrl);
    4.});

     

     

    Steps to Debug stored procedure of SQL server 2008 using Visual Studio 2010


    Perform all these steps on machine where SQL server is installed
    1.  Window key + R and Write:  compmgmt.msc

    2.  Above step will open computer management dialog, in the left pane expand tree view from system tools >> local users and groups >> groups. Double click “Administrators” which appear in the right pane, As shown below

    3.   On double clicking Administrators following dialog appears, in which you have to add the user name from where you are going to connect to the server using visual studio 2010 and want to debug. So to add user click add button as shown below.

    4.  When Add… button is clicked following dialog appears, in which you give user name and click ok as shown in below dialog box.

    5.  Now switch to the visual studio 2010, and open “Server Explorer“, and then click “connect to database” button as shown below.

    6.  Fill all the information in the “Add connection” dialog. As shown below.

    7.  You can click “Test connection” button to test connection. As shown below


    8.  Expand stored procedure folder under the SQL server name and double click the stored procedure which you want to debug for e.g. “addimg”, Now Double clicking it will result in displaying the script of the stored procedure. Then put the breakpoint in your desired location in the script. As shown below

    9.  Now right click the same stored procedure and select “Step into Stored procedure” from the context menu which appear on right click, As shown below

    10.  Following “Run stored procedure” dialog will appear in which you need to fill all the input parameters which are declared when the stored procedure is created.

    11.   Bingo…..Success in debugging the stored procedure