Programming and web development are passions of mine, and I hope to have something useful to contribute to the community either through my work or through this blog.
Nov 20, 2009
Register IIS
Can you try running %windir%\microsoft.net\framework\v2.0.50727\aspnet_regiis -i -enable
That should reset the permissions and reregister ASP.Net on your server.
Oct 5, 2009
Finding Blank Lines using regular expressions
In this regular expression we are going to find out blank lines. Means we are going to search lines containing only spaces (or Whitespace) and end of line.
Regular Expression Pattern
^\s*$
A description of the regular expression:
Beginning of line or string
Whitespace, any number of repetitions
End of line or string
How It Works
This regular expression will check for blank lines contains only spaces (Whitespace). Here we are going to search Beginning of line followed by Whitespace, any number of repetitions and End of line or string.
Finding Blank Lines using regular expressions
ASP.NET
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
C#.NET
//use System.Text.RegularExpressions befour using this function
public bool vldRegex(string strInput)
{
//create Regular Expression Match pattern object
Regex myRegex = new Regex("^\\s*$");
//boolean variable to hold the status
bool isValid = false;
if (string.IsNullOrEmpty(strInput))
{
isValid = false;
}
else
{
isValid = myRegex.IsMatch(strInput);
}
//return the results
return isValid;
}
VB.NET
‘Imports System.Text.RegularExpressions befour using this function
Public Function vldRegex(ByVal strInput As String) As Boolean
‘create Regular Expression Match pattern object
Dim myRegex As New Regex("^\s*$")
‘boolean variable to hold the status
Dim isValid As Boolean = False
If strInput = "" Then
isValid = False
Else
isValid = myRegex.IsMatch(strInput)
End If
‘return the results
Return isValid
End Function
Sep 30, 2009
Some important LINKS
http://support.microsoft.com/kb/959209
ASP.NET Compilation Enhancement Fix
http://code.msdn.microsoft.com/KB967535/Release/ProjectReleases.aspx?ReleaseId=2328 (for Windows Vista and Windows Server 2008)https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=18157 (for Windows XP and Windows Server 2003)
Microsoft .NET RIA Services May 2009 Preview
http://www.microsoft.com/downloads/details.aspx?FamilyID=76bb3a07-3846-4564-b0c3-27972bcaabce&displaylang=en
ASP.NET 4.0 in VS 2010 Doc
http://www.asp.net/learn/whitepapers/aspnet40
Some of them are a little old but thought worth putting them up.
Cheers !!!
Sep 18, 2009
Creating multiple websites on a single IP ...
There are three options to host multiple websites in IIS :
1. Create websites, each assigned an IP - The downside of this option is that you will have limited IPs with you !!
2. Create websites, each listening on different port numbers.For example, http://mysite1.com and http://mysite2.com:8888 - The downside of this approach is that users have to remember the port number of the site that they are interested in!!
3. Using Host-Headers - This option is the "best" that solves the problem at hand.
Let me elaborate a bit on option #3 here:
1. Create multiple websites in IIS
2. Right click on a website, choose "Properties".
3. On the tab page named "Website" click "Advanced ..." and here you can add a host header (say, mysite2.com) and let all the websites have the IP as "All Unassigned" and the port 80.
Having done this, update the DNS records for mysite1.com and mysite2.com to point to the IP running your webserver and try accessing mysite1.com and mysite2.com, it works :-)
For more details, please visit http://www.iisanswers.com/Top10FAQ/t10-hostheaders.htm
Sep 17, 2009
Set Height Width Color of Rad Confirm Window in Radgrid Button Column
.RadWindow .rwWindowContent .radconfirm,
{
color:White !important;
}
.RadWindow .windowpopup.radconfirm
{
height: 150px !important;
width: 300px !important;
}
style
Aug 31, 2009
How to publish asp.net web application and protect its source code
by admin on August 4, 2009
Sometimes you need to deploy your web application whilst protecting your source code. In that case, you can compile the code into a single .dll file. Please note that only code files (such as .vb and .cs) can be compiled, not the markup files (aspx, ascx, etc).
In order to get it to work, you need to perform few steps.
Step 1: Open solution with your web application and build (”Build > Build ProjectName” menu”)
Step 2: Open Solution Explorer (”View > Solution Explorer” menu). Right click your web project node. Select “Publish“. Although you can publish to different locations, it would be more flexible to publish the project into local directory on the hard drive. This way you can obfuscate your dll before the actual publishing. Type relative (e.g. “mypublishdir”) or absolute (”C:programmingmypublishdir”) path and click “Publish”.
Step 3 (optional): In case if you need additional protection for your source code, you can obfuscate the dll now. Navigate to a folder with the published files, then “bin” and obfuscate the dll file as needed. I prefer Eazfuscator.NET for obfuscation, since it’s free and easy to use. You don’t need to obfuscate other files. Obfuscation makes it difficult for someone to extract source code from your dll.
Step 4: Upload all received files to your webserver via FTP, webmanager or Remote Desktop.
Done!
Global Assembly Cache (GAC) and the .Net Assembly And What is SBI ?
1. How should we add an assembly reference?
If a DLL project is referenced in an application, using Add Reference--> Projects, the referenced DLL has the source path as one of the following:
DLL in the release folder.
Note: DotNet does not considers whether the .dll is available in the release folder or not.
Incase release folder is not available then the .dll will refer the debug folder.
If the reference file is selected explicitly to point debug or release the selected folder is referenced.
2. How should an assembly be uninstalled
Uninstalling an assembly should be done with care.
The following command removes the assembly hello from the global assembly cache(GAC) as long as no reference counts exist for the assembly.
gacutil /u hello
Note : If there is only one version of hello assembly the above command is fine and you are in safer side. Incase if there are more than one version of the assembly or different assembly with same name exists then the above command might remove more than one assembly from the assembly cache because the assembly name is not fully specified. For example, if both version 1.0.0.0 and 3.2.2.1 of hello are installed in the cache, the command gacutil /u hello removes both of the assemblies.
Then how to remove the assembly safely: Use the following example to avoid removing more than one assembly. This command removes only the hello assembly that matches the fully specified version number, culture, and public key.
gacutil /u hello, Version=1.0.0.1, Culture="de", PublicKeyToken=45e343aae32233ca
3. Can I delete the source file which I have used to register in GAC
Yes, the assembly makes a copy in the GAC folder. So the source file can be deleted.
4. Can I specify the space used by GAC?
Yes, Navigate to the GAC directory, C:\winnt\Assembly in explore. In the tools menu select the cache properties; in the windows displayed you can set the memory limit in MB used by the GAC.
5. Why I should use Assemblies.
The .NET Framework uses assemblies as the fundamental unit for several purposes:
· Security
· Type Identity
· Reference Scope
· Versioning
· Deployment
6. What is Versioning?
Each assembly has a 128-bit version number that is presented as a set of four decimal pieces: Major.Minor.Build.Revision
For example, an assembly might have the version number 3.5.0.126.
By default, an assembly will only use types from the exact same assembly (name and version number) that it was built and tested with. That is, if you have an assembly that uses a type from version 1.0.0.2 of another assembly, it will (by default) not use the same type from version 1.0.0.4 of the other assembly. This use of both name and version to identify referenced assemblies helps avoid the "DLL Hell" problem of upgrades to one application breaking other applications.
Tip An administrator or developer can use configuration files to relax this strict version checking. Look for information on publisher policy in the .NET Framework Developer's Guide.
7. Can my assembly span more that one file?
Yes, assembly can have more that one file. Each file can be developed from different language too. Using the al.exe utility all the required files are grouped and made into single file.
8. How do I decide whether my assembly should contain only one DLL or a collection of dlls?
A typical assembly is a single DLL described by an assembly manifest. An assembly may contain multiple files. In cases where components have tight interdependencies such that if you make changes to one component the other would also change, it makes sense to include the group of files in the same assembly.
When deciding what to include in your assembly, keep in mind how you intend to manage these in the future, and how you want applications to use them. For example, if you include two files in an assembly, each time you ship a new version of the assembly, you would include both files, whether or not both have changed. If you have two files with a strong interdependency, and you decide to ship as separate assemblies, you need to be aware that customers have a choice of mixing versions. If you update both assemblies, a customer may choose to use the new version of one and the older version of the other, which may or may not be compatible
9. Which type of reference is advantageous during development and why? Referencing the exact dll path or the project itself in a solution with more than one project, with one or more class lib project?
Referring, project itself is right and advantages, for the following reasons:
They automatically track project configuration changes. For example, when you build using a debug configuration, any project references refer to debug assemblies generated by the referenced projects, while they refer to release assemblies in a release configuration. This means that you can automatically switch from debug to release builds across projects without having to reset references.
10. What are the types of caches available in .Net ?
1) GAC, or Global Assembly Cache - all shared assemblies live here
2) Download Cache - when you execute an assembly from a URL, this is where the downloaded assemblies end up
3) 'ZAP' Cache - this cache seems to serve as the home for pre-compiled native assembly images that are produced by NGEN
11. What is called probing?
Private assemblies are deployed within the directory structure of the application in which they are used. Private assemblies can be placed directly in the application directory, or in a subdirectory thereof. The CLR finds these assemblies through a process called probing. Probing is simply a mapping of the assembly name to the name of the file that contains the manifest.
12. If the same assembly is used by two app, what will be store in GAC and how it is stored.
In GAC, only one master copy of the dll is stored. But if another application is installing the same assembly (with the same version) a reference with a native image is created.
So if we have a dll, which is used by three applications, there will be one master and two images in the GAC.
You can see this when you check the GAC folder. In COM you can't have same dlls with different versions.
13. What do you call as DLL Hell in COM and how was that fixed in .Net.
Let’s consider a shared dll used by msn messenger and your own application. When you upgrade MSN Messenger, a new version of shared dll will be installed which may not be compatible with your application, which leads in failure of your application. This scenario is described as DLL Hell.
In .Net the problem is fixed using GAC - shared assembly, where you can have more than one version of the same dll. If new version of msn is installed, the new version of the dll in installed in GAC with the new version number. The important thing in GAC is that, more than one version of same dll can co-exist, so older version of dll, which is referenced by your application, will not get affected.
14. How to override the assembly name and version combination key while selecting and using the assembly in the GAC?
By default the assembly for the application is binded during installation.
The assembly is selected by name and the version from the GAC, sometimes we require our application to use another version of the same assembly. For example
An administrator may deploy a critical bug fix to a shared assembly and want all applications to use this new version regardless of which version they were built with. Also, the vendor of a shared assembly may have shipped a service release to an existing assembly and would like all applications to begin using the service release instead of the original version. These scenarios and others are supported in the .NET Framework through version policies.
Version policies are stated in XML files and are simply a request to load one version of assembly instead of another. For example, the following version policy directs the CLR to load version 5.0.0.1 instead of version 5.0.0.0 of an assembly called MarineCtrl:
In addition to redirecting from a specific version number to another, you can also redirect from a range of versions to another version. For example, the following policy redirects all versions from 0.0.0.0 through 5.0.0.0 of MarineCtrl to version 5.0.0.1:
15. What are the types of version policy levels
Application-specific Policy. Each application has an optional configuration file that can specify the application’s desire to bind to a different version of a dependent assembly. The name of the configuration file varies based on the application type. For executable files, the name of the configuration file is the name of the executable plus a ".config" extension. For example, the configuration file for "myapp.exe" would be "myapp.exe.config". Configuration files for ASP.NET applications are always "web.config".
Publisher Policy. While application-specific policy is set either by the application developer or administrator, publisher policy is set by the vendor of the shared assembly. Publisher policy is the vendor’s statement of compatibility regarding different versions of her assembly. For example, say the vendor of a shared Windows Forms control ships a service release that contains a number of bug fixes to the control. The original control was version 2.0.0.0 and the version of the service release is 2.0.0.1. Because the new release just contains bug fixes (no breaking API changes) the control vendor would likely issue publisher policy with the new release that causes existing applications that used 2.0.0.0 to now start using 2.0.0.1. Publisher policy is expressed in XML just as application and machine-wide policy are, but unlike those other policy levels, publisher policy is distributed as an assembly itself. The primary reason for this is to ensure that the organization releasing the policy for a particular assembly is the same organization that released the assembly itself. This is accomplished by requiring that both the original assembly and the policy assembly are given a strong name with the same key-pair.
Machine-wide Policy. The final policy level is machine-wide policy (sometimes referred to as Administrator policy). Machine-wide policy is stored in machine.config which is located in the "config" subdirectory under the .NET Framework install directory. The install directory is %windir%\microsoft.net\framework\%runtimeversion%. Policy statements made in machine.config affect all applications running on the machine. Machine-wide policy is used by Administrators to force all applications on a given machine to use a particular version of an assembly. The most common scenario in which this is used is when a security or other critical bug fix has been deployed to the global assembly cache. After deploying the fixed assembly, the Administrator would use machine-wide version policy to ensure that applications don’t use the old, broken version of the assembly.
16. What is Native image file for an assembly?
A native image is a file containing compiled processor-specific machine code. Note that the native image that Ngen.exe generates cannot be shared across Application Domains. Therefore, you cannot use Ngen.exe in application scenarios, such as ASP.NET, that require assemblies to be shared across application domains.
Pre-compiling assemblies with Ngen.exe can improve the startup time for applications, because much of the work required to execute code has been done in advance. Therefore, it is more appropriate to use Ngen.exe for client-side applications where you have determined that the CPU cycles consumed by JIT compilation cause slower performance.
17. Can I limit the space used by GAC?
Yes, the size of the GAC can be modified as per the requirements. To set the size, browse through the gac folder %windir%\Assembly\ in windows explorer.
Select Toolsà Cache Options from the menu to set the maximum size of the disk space to be allotted for GAC.
18. How do I see the physical file structure of cache in explorer?
It is possible to see physical file structure of GAC folder.
As such Winnt\assembly\gac cannot be browsed using windows explorer.
To view the physical file structure add a binary value named 'DisableCacheViewer' to the registry key HKLM\Software\Microsoft\Fusion and set it to a non-zero value.
What do you meant by "SBI" of an object?
# 1 SBI stands for State, Behavior and Identity. Since every
object has the above three.
* State:
It is just a value to the attribute of an object at a
particular time.
* Behaviour:
It describes the actions and their reactions of that object.
* Identity:
An object has an identity that characterizes its own
existence. The identity makes it possible to distinguish
any object in an unambiguous way, and independently from
its state.
Aug 21, 2009
Add/Remove RadControls to the Global Assembly Cache
Add/Remove RadControls to the Global Assembly Cache
Installation and deployment > Deploying RadControls for ASP.NET AJAX > Add/Remove RadControls to the Global Assembly Cache
Glossary Item Box
Add to Global Assembly Cache
There are two ways to add a control to the Global Assembly Cache (GAC):
Automatic
1. Go to Start -> Settings -> Control Panel -> Administrative Tools -> Microsoft .NET Framework 2.0 Configuration
2. Expand the nodes and locate Assembly cache
3. Right-click on it and select Add:
Microsoft .NET 2.0 Configuration panel
4. Browse to the Telerik bin directory and ctrl-highlight the needed DLL's (the demo and DictionaryConfiguration DLLs are not needed).
5. Click Open.
Manual
1. Run the .NET command prompt (Start -> Programs -> Microsoft VS.NET -> VS.NET Tools -> VS.NET prompt) and start the gacutil.exe tool with -i parameter (install) and the name of the control, e.g.
[VS prompt] Copy Code
gacutil.exe -i "C:\Program Files\Telerik\RadControls for ASPNET AJAX\Bin\Telerik.Web.UI.dll"
You may also directly copy the dll files to the "\WINDOWS\assembly" (or "\WINNT\assembly") folder of your server - this is equivalent to the effect of the gacutil.exe utility.
2. Change the machine.config file of the server and add a reference to the assembly in the GAC. The machine.config file is the configuration file for all web applications on the server. It is located at: "\WINDOWS\Microsoft.NET\Framework\[Framework Version]\CONFIG". It is similar in to the web.config file, but the web.config only works for the web application, in which it resides.
Locate the
[machine.config] Copy Code
To get the information that goes into the assembly attribute (version, culture, PublicKeyToken), you can run the gacutil /l command, which will return a list of all the assemblies in the GAC. You will have to look for the one you just added and copy the assembly name, version, culture and publickeytoken.
For example the following command:
[VS prompt] Copy Code
gacutil -l Telerik.Web.UI
will return:
[VS prompt] Copy Code
Telerik.Web.UI, Version=[Assembly.Version], Culture=neutral,
PublicKeyToken=121fae78165ba3d4, processorArchitecture=x86
so the correct entry in the machine.config should be:
[machine.config] Copy Code
After that you should be able to use the control in all the application on the server without having to copy it to the "bin" folder of each web-application.
Remove from Global Assembly Cache
In order to remove Telerik RadControls for ASP.NET AJAX from GAC, please use the following command:
[VS prompt] Copy Code
gacutil.exe -u Telerik.Web.UI
Aug 7, 2009
Allowed file types are .vb, .cs, and .zip. Zip files will be automatically expanded on the server and all .vb and .cs files will be extracted.
Aug 5, 2009
Retrieving Keys of Selected Items in Telerik RadGrid
Here is how Telerik suggests getting the primary key for the first selected item in a RadGrid:
RadGrid1.SelectedItems[0].OwnerTableView.DataKeyValues[RadGrid1.SelectedItems[0].ItemIndex]["CustomerID"]
I guess something like:
RadGrid1.SelectedItems[0].Value
would have been too obvious. Anyway, here is a helper routine I wrote to hand back an ArrayList containing the selected keys:
#region GetTelerikGridSelections
public ArrayList GetTelerikGridSelections(Telerik.Web.UI.RadGrid grid)
{
ArrayList selectedItems = new ArrayList();
if (grid.MasterTableView.DataKeyNames.Length > 0)
{
string key = grid.MasterTableView.DataKeyNames[0];
for (int i = 0; i < grid.SelectedItems.Count; i++)
{
selectedItems.Add(grid.MasterTableView.DataKeyValues[grid.SelectedItems[i].ItemIndex][key]);
}
}
return selectedItems;
}
#endregion
I used an ArrayList rather than a strongly-typed collection to make it more flexible, but if you always use the same data type for your keys, you could change this to save yourself some effort. Note: this only looks at the MasterTableView. If you are using multiple table views in your grid you should also tweak this to receive a GridTableView instead of a RadGrid.
Making Rad Grid Case Sensitive
RadGrid1.GroupingSettings.CaseSensitive = false;
Jul 15, 2009
Failed to access IIS metabase.
Problem
Failed to access IIS metabase.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.Hosting.HostingEnvironmentException: Failed to access IIS metabase.
The process account used to run ASP.NET must have read access to the IIS metabase (e.g. IIS://servername/W3SVC). For information on modifying metabase permissions, please see http://support.microsoft.com/?kbid=267904.
Solution :-
This Error Caused Because You Not Have Register ASP.Net with IIS.Please Follow Following Step to Regiser ASP.Net With IIS.
-> Go to Start - > Run -> Cmd.
-> GO to Your System Drive Mostly C Drive.
-> Type C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -i
Just wait And Message comes Successfully Register.
Unable to start debugging on the web server.
Following Error Comes When web Server is not configured correctly
"Unable to start debugging on the web server. The web server is not configured correctly. See help for common configuration errors. Running the web page outside of the debugger may provide further information."
Do the Following Step To resolve This Error
Step 1 : Open IIS ( Internet Information Service )
To Open IIS start >> Run Window >> Writr "inetmgr" Click Ok
Step 2 : Select your Application Directory Or Virtual Directory
Step 3 : Right Click On Application Directory Click On Create Button ( on Directory Tab )
Step 4 : Go On Asp.net Tab and Select correct Asp.net version .
Step 5 : Finally CLick On Apply .
Error solution
Failed to access IIS metabase.
This Problems occurs When you have both Microsoft Dot Net 2003 And 2005 in Your Pc .
In This Case You have to Install IIS After insalling .NET framework .
Do this Following Steps To resolve "Failed to access IIS metabase " issue
Step 1. repair .net
Step 2.Run This Command From Run Command Window ( Start >> Run ):-
"c:\WINNT\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -i "
Finally Check ASP.NET version is associated with the virtual directory .
For That Do Following :-
- Right Click virtual directory name
- Select Properties
- Then ASP.NET tab
- Select ASP.Net Version
Hope So , This Will Help U ..
Jul 10, 2009
Regular Expression Important
The Regex class contains several static methods that allow you to use a regular expression without explicitly creating a Regex object. Using a static method is equivalent to constructing a Regex object, using it once and then destroying it.
Sample Code 1
Imports System.Text.RegularExpressions
' import the namespace
'instantiate the objects
dim oRegex as new regex("test pattern")
'use the object
If oRegex.IsMatch("this is the string to test on") Then
msgbox "Match found"
else
msgbox "Did not find match"
end i
Sample Code 2
//Check for correct format of your name
Dim myMatch As Match = System.Text.RegularExpressions.Regex.Match(InsertYourName, "^[A-Z][a-zA-Z]*$")
If Not myMatch.Success Then
'Name was incorrect
ErrorMessage("Invalid Name", "Message")
txtFname.Focus()
Return
End If
Regular Expressions Elements:
* . Character except a newline character(\n)
* \d Any decimal digit
* \D Any nondigit
* \s Any white-space character
* \S Any Non-white-space charater
* \w Any word character
* \W Any nonword character
* ^ Beginning of string or line
* \A Beginning of string
* $ End of string or line
* \z End of string
* | Matches one of the expressions seprated by the vertical bar; example eee|ttt will match one of eee or ttt (tracing left to right)
* [abc] Match with one of the characters; example [rghy] will match r, g,h or c not any other character.
* [^abc] Match with any of character except in list; example [ghj] will match all character except g,h or k.
* [a-z] Match any character within specified range; example [a - c] will match a, b or c.
* ( ) Subexpression treated as a single element by regular expression elements described in this table.
* ? Match one or zero occurrences of the previous character or subexpression; example a?b will match a or ab not aab.
* * Match zero or more occurences of the previous character or subexpression; example a*b will match b, ab, aab and so on.
* + Match one or more occurences of the previous character or subexpression; example a+b will match ab, aab and so on but not b.
* {n} Match exactly n occurrences of the preceding character;example a{2} will match only aa.
* {n,} Match minimum n occurrences of the preceding character;example a{2,} will match only aa,aaa and so on.
* {n,m} Match minimum n and maximum n occurrences of the preceding character;example a{2, 4} will match aa, aaa, aaaa but not aaaaa.
Jul 7, 2009
Sending Mail Using GMAIL in your Application
' Sending Mail to Multiple Recipient
Dim mails As Net.Mail.MailMessage = New Net.Mail.MailMessage()
Try
mails.To.Add(txtemail.Text)
mails.From() = New MailAddress("Your mail id here")
mails.Subject() = txtsubject.Text
mails.IsBodyHtml = True
mails.Body = texteditor.Content
'Attaching the File
Dim attachFile As New Attachment(Server.MapPath("Attachfile.doc"))
mails.Attachments.Add(attachFile)
Dim SMTPServer As New SmtpClient("smtp.gmail.com")
SMTPServer.Port = 587
SMTPServer.Credentials = New System.Net.NetworkCredential("yourmailidhere@gmail.com", "password")
SMTPServer.EnableSsl = True
SMTPServer.Send(mails)
Catch ex As Exception
End Try
End Sub
Jul 4, 2009
Easily refresh an UpdatePanel, using JavaScript
I’ve noticed a lot of discussion lately regarding methods to refresh an UpdatePanel via client script. This is very easy on the server side, of course. You can just call UpdatePanel.Update(). However, on the client side, the most common solutions I’ve been seeing just don’t feel right.
Many will advise you to use a hidden button control inside the UpdatePanel, manipulated via button.click(), to trigger a partial postback of the UpdatePanel. While it does work, I never have been able to get past the kludgey nature of that solution.
Finding a better way
To find a better solution, we’ll need a demonstration UpdatePanel to experiment with:
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div id="Container">
<asp:UpdatePanel runat="server" ID="UpdatePanel1"
OnLoad="UpdatePanel1_Load">
<ContentTemplate>
<asp:Label runat="server" ID="Label1" />
ContentTemplate>
asp:UpdatePanel>
protected void UpdatePanel1_Load(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
}
That’s a slightly modified version of the standard UpdatePanel DateTime example. Instead of the more commonly used Button_Click trigger, notice that the UpdatePanel’s OnLoad event is handled in code-behind.
Anytime UpdatePanel1 is loaded or reloaded in a postback, Label1 will be updated to reflect the current date and time.
Never fear, __doPostBack() is here
Luckily, there’s an easy method for triggering a postback targeted at the UpdatePanel: __doPostBack().
As long as the event target of a __doPostBack() call is an async trigger of an UpdatePanel, the ASP.NET AJAX framework will intercept the postback and fire a partial postback instead. For purposes of demonstration, I’m going to add that to the OnClick event of the container div:
<div id="Container" onclick="__doPostBack('UpdatePanel1', '');">
Now, clicking anywhere in the UpdatePanel will trigger a partial postback, targeting the UpdatePanel. Since partial postbacks follow the full page lifecycle, this will fire UpdatePanel1_Load and update the Label’s text.
A word on _doPostBack
You may have noticed that there is also an ASP.NET AJAX specific method of the PageRequestManager named _doPostBack. While it works much like __doPostBack, as long as the ASP.NET AJAX client framework is present, you should not call it directly.
The original __doPostBack method performs identically, but is more robust since it gracefully degrades to full postbacks when the ASP.NET AJAX framework isn’t available. It’s also unlikely that __doPostBack will disappear in future versions of ASP.NET, while it’s less assured that the ASP.NET AJAX framework will remain unchanged.
Did you know… Visual Studio has several different search options?
Did you know… Visual Studio has several different search options?
The standard methods for searching can be found under the Edit --> Find and Replace menu.
The “Quick Find” method (Ctrl+F) allows users to search inside of the current document, all open documents, the current project, the entire solution, and the current block by changing the Look in selection.
If you set Look in to be the current project or the entire solution, Visual studio will open files that have matches as you navigate between matches.
You can also adjust the settings under Find options to make the searches more specific by having them match on case or whole words or control how it searches by deciding whether it should search up or down or if it should look at hidden text (collapsed regions).
The Find in Files method (Ctrl+Shift+F) allows users to see all the occurrences of the search in one place, changes the Look in options by removing the current block, but allows users to search custom locations by using the “…” button next to the Look in drop down, and allows the user to restrict the types of files searched.
If you use Ctrl+F or select the Quick Find option from the find and replace menu by mistake, hitting Ctrl+Shift+F or selecting the drop down in the upper left corner of the dialog and selecting Find In Files will quickly get you to the Find in Files dialog.
Using the Result options section you choose to have the results displayed in either the “Find Results 1” or “Find results 2” window. Allowing you to switch between results if needed.
The Find What field also keeps a history of searches. To access this history click the down arrow of the Find What field. You can avoid using the history or typing search terms by having the value you want to search for selected in the editor before opening one of the find dialogs.
Did you know… You can now do Multiple Selection of controls in your Designer with VS 2008 SP1?
Did you know… You can now do Multiple Selection of controls in your Designer with VS 2008 SP1?
Visual Web developer 2008 SP1 supports multiple selection of controls on your designer using Ctrl+Click.
You can see that the designer:
- Displays the primary selected control with a white tab. Button3 in the image below.
- Enable you to set property for the selected controls using Property Grid. Note that the property grid would show you only the properties that are in common for all the selected controls.
- Enables you to make use of the Align, Make Same Size and Order Menu commands in your Format Menu options.
However VWD 2008 SP1 does not support the ability to drag drop multiple controls and Cut/Copy/Paste of multiple elements.
Thanks!
Windows 7 Release Candidate Announcement
Windows 7 Release Candidate Announcement
Microsoft is ready to release its next version of window named windows 7.
From April 30 ,2009 the RC is available to MSDN subscribers and TechNet Plus subscribers.
From May 5 (PST),2009 , the RC will be available to everyone via our Customer Preview Program. As with the Beta, the Windows 7 RC Customer Preview Program is a broad public program that offers the RC free to anyone who wants to download it. It will be available at least through June 30, 2009, with no limits on the number of downloads or product keys available.
With "Faster & easier" product tag line windows 7 is equipped with lot of new stuff that the user is bound to like. please visit "what's new in windows-7" at windows 7 portal.
for more information see latest Microsoft press release on
ASP.NET File Upload like GMail
ASP.NET File Upload like GMail
Ajax Uploader is an easy to use, hi-performance File Upload Control which allows you to upload files to web server without refreshing the page.
It allows you select and upload multiple files and cancel running uploads, add new files during uploading.
Ajax Uploader allows you to upload large files to a server with the low server memory consumption. The look and feel of file upload controls can be customized to seamlessly blend into your website design.
http://ajaxuploader.com/