z
 
:: Home     :: MS Dynamics CRM     :: .Net 1.1     :: .Net 2.0     :: Sharepoint Portal     :: Ajax

  login:        
  passwords:  
 

Resources

Finding Correct Content Managemet System
This list covers the full lifecycle of a content management system, from initially creating the content, through to delivering it to end users...

Workflow Managemet Systems
Workflow management is a crucial component in organizing a variety of business processes so that they benefit the business as a whole and increase profitability...

Using the Power of Content Management Systems
With page editors that resemble a word processor program, adding content with a CMS interface is simple and fun. Most CMS software also allows you to change the location of your content pages and links easily, while the back end processes takes care of updating the links throughout your site...

Content Management Systems (CMS): What They Are And Why We Love Them
In the past, individuals who took interest in having and operating their own websites were burdened with the task of learning HTML, DHTML, and other web-based technologies such as JavaScript and CSS. The only alternative to this was, unfortunately, to pocket the expenses and costs required to pay a web developer to build and maintain it for them...

Outsourcing
Post your project for outsourcing and get bids from qualified programmers, designers, interpreters, copywriters.


 

Code Walkthroughs

Datagrid Formatting the Data
We are able to format the content of the datagrid cell by one of two simple methods, dependant upon whether the column is a bound column or whether it is a template column. In our example we shall format the column to have to digits after the decimal point , followed by a...

Datagrid Highlight a Row With Click Through
It is relatively easy to add alternating colours to the rows in your datagrid. However, when we move the mouse over the rows we may want to highlight this row, and possibly to add the option of a click through based on the row selected...

Add a Delete Button to a Datagrid
To add a delete button to a datagrid follows a similar process to adding an edit button. In the datagrid header...

Add an Edit Button to a Datagrid
The datagrid has a predefined editColumn for handling the editing of a datagrid. Adding this simple column definition to a datagrid adds a powerful feature. When a row is not in edit mode the column item shows the word...

Making a Datagrid Row Editable
Two of the most popular methods of editing a datagrid in asp.net are to either select the row and take the user off to a different presentation of the data, or to change the formatting of the row presented in the database with appropriate edit text boxes, checkboxes and...

Adding Tooltips to Datagrid Rows
Adding tooltips to datagrid rows is easy, assuming that you have already created the code for adding row highlighting. In this article I shall assume that you have already read the article entitled Datagrid Highlight a Row With Click Through...

Binding a Datagrid to an Access Database
This list covers the full lifecycle of a content management system, from initially creating the content, through to delivering it to end users...

Adding Data to a DropDownList
The aim of this article is to answer the question 'How do I add items to a DropDownList?' Initially as part of the declaration for the DropDownList we can also define a number of items, much in the same way as in classic ASP...

Getting Current Date Time
In classic ASP we had now() which would return the current date and time. For asp.net this no longer exists. So what should we use...

Test if File Exists
Sometimes, in order to reduce our chance of error, when working with the filesystem in ASP.NET, we need to determine wether a file exists before performing an action on it. The following short piece of code will enable us to test whether a file exists...

Using Javascript with ASP.NET Form Elements
Adding simple pieces of Javascript to an Asp.net page can be acheived by adding to the attributes of the particular imagebutton or linkbutton. if its normal ASP.Net Button then you can...

Regular Expressions
In the table below we list the characters used in .Net regular expressions, together with their meaning, But first...

Authentication in Asp.net
Forms authentication in ASP.Net is far more easier and safe than Asp 3. It is possible to place a web.config file in any directory of a web site.Therefore, we are able to make most of a web site public, whilst providing authentication on, say, one directory...

Discussion Forums

General ASP.NET

.Net Programming

cSharp Home

Sql Server Home

Javascript / Client Side Development

IT Jobs

Ajax Programming

Ruby on Rails Development

Perl Programming

C Programming Language

C++ Programming

Python Programming Language

Laptop Suggestions?

TCL Scripting

Fortran Programming

Scheme Programming

4. Miscellaneous

FAQ Home
   4.1 How to get the currently logged in user?
   4.2 How to specify a line break in a Label's Text?
   4.3 How to convert a string to HTML format?
   4.4 How do I determine if the user clicked a "Submit" button twice in the page?
   4.5 How to write date-time values of fields in a dataset into xml in a specific format?
   4.6 What does "~" mean in ASP.NET applications?
   4.7 How can I reference simple DLL which contains one class but has no namespace assigned to it in an .aspx page?
   4.8 How do I specify the Japanese locale for the controls in my Japanese localized page?
   4.9 Why do some of the events on my page fire twice?
   4.10 How to remove the spaces in a given string?
   4.11 I get the error System.__ComObject when using recordset?
   4.12 Why do I get error "A generic error occurred in GDI+." when trying to save the bitmap file?
   4.13 How can I force a Save As dialog box from an ASP.NET Web page.
   4.14 In ASP.NET is there a control similar to Combobox in Windows forms?
   4.15 How to do text encryption and decryption?
   4.16 How can I trigger a submit on my form when the enter key is pressed?
   4.17 How to get list of all files in the directory?
   4.18 What is HttpHandler?
   4.19 How to get the size of a byte array?
   4.20 How to know the width and height in pixels of a given image programmatically?
   4.21 When using FormsAuthentication, how can I redirect a user to a different page other than the default page?
   4.22 Is there a control in ASP.NET for geting HTML like the ASPHTTP for the classic asp.
   4.23 Why do I get error message "System.Web.HttpException: Request is not available in this context" " when using Cookies?
   4.24 How to save the Output of ASP.NET to HTML?
   4.25 Why do I get ViewState error when upgrading my application from a single web server to a web farm?
   4.26 How to convert Color to it's corresponding Hexadecimal value?
   4.27 How to Select a record using Listbox and edit/update it's fields using textboxes?
   4.28 How to select a value from a child form and send it to parent form?
   4.29 How to read the comma seperated values from a string?
   4.30 How do I make my TextBox positioned below a DataGrid move up or down in position as the height of the DataGrid changes?
   4.31 How to stamp Date-Time on all the pages in an application when requested?
   4.32 How can I have multiple command buttons map to the same event or function?
   4.33 How to use a RangeValidator to select Colors from a specific range?
   4.34 How to restore the browser's scroll position after a postback?
   4.35 Is there something as RecordSet we had in ASP that can be used in ASP.NET?
   4.36 How to set a <link> tag's href attribute at runtime using a value specified in the web.config file?
   4.37 How to call the Page_load procedure from any event on the page?
   4.38 How to add login user (ASPNET) to MS SQL 2000 Desktop Engine server?
   4.39 How to get the count of rows in a Excel file?
   4.40 What are the pros and cons of using Session or Cache to save intermediate state?
   4.41 How to mirror (align elements Right to Left) a form or control on a form?
   4.42 How can I Enable ASPX Compression in IIS?
   4.43 How to run an exe from a ASP.NET page?
   4.44 Why does FormsAuthentication.Decrypt crashes when moving to another Server?
   4.45 Why do I get error message "Login failed for user DOMAIN\USERNAME"?
   4.46 How to check if the current User has been Authenticated?
   4.47 How to get the Computer Name on which the code is running?
   4.48 How to pass argument to accessdatasourcecontrol selectcommand statement?
   4.49 How to compile CS/VB file and place new DLL in bin subdirectory?
   4.50 Can I use a src attribute with a Web Service?
   4.51 How to display random images on a web page from a set of images in a directory?
   4.52 How can I scan a string to determine if it contains DBCS chars?
   4.53 Request.ServerVariables("LOGON_USER") always returns empty string in Framework 1.1 . Why? It worked fine in ASP?
   4.54 Is there a way to specify CSS only if the browser is IE?
   4.55 How to create Custom Application Settings in the web.config?
   4.56 Why do I get "do not have permissions" error when accessing a Access mdb file in my local system?
   4.57 How can I access an MS Access database in my ASPX page, if the db is on a remote server?

4.1 How to get the currently logged in user?


To get the user ID of the user who is currently logged in, you would get it using this: System.Web.HttpContext.Current.User.Identity.Name VB.NET


'Displays the currently logged in user
Response.Write(User.Identity.Name.ToString())


C#


//Displays the currently logged in user
Response.Write(User.Identity.Name.ToString());



4.2 How to specify a line break in a Label's Text?


Use the "<br>" tag to specify line breaks. For example:

VB.NET


Label1.Text = "<sometag1>" + "<br>" + "<sometag1>"


C#


Label1.Text = "<sometag1>" + "<br>" + "<sometag1>";



4.3 How to convert a string to HTML format?


Use namespace System.Web.HttpUtility
VB.NET


Dim mystring as string =”Tom & Jerry”
Response.Write (HttpUtility.HtmlDecode (mystring))


C#


string mystring=”Tom & Jerry”;
Response.Write (HttpUtility.HtmlDecode (mystring));



4.4 How do I determine if the user clicked a "Submit" button twice in the page?


Check out Andy Smith's OneClick Control


4.5 How to write date-time values of fields in a dataset into xml in a specific format?


Refer Format DateTime Values in XML extracted from Dataset


4.6 What does "~" mean in ASP.NET applications?


The tilde (~) in front of URLs means that these URLs point to the root of your web application.

Web developers are familiar with using relative paths for all links, including hyperlinks, images, and stylesheets, to be able to move around web pages collectively.

In ASP.NET when using User controls the relative paths can be difficult to use. The typical solution to this is to use web-root absolute paths instead here, resulting in the hard-coded sub-directories that are common on ASP.NET sites.

The correct solution to this problem is to use app-relative paths instead, which ASP.NET nicely makes possible through the use of the tilde (~) prefix. Instead of <a href="/UC/Page.aspx">, use <a href="~/Page.aspx" runat="server">. The same ~ notation works for images also, as long as you add runat="server". There is also a ResolveUrl method that allows you to use ~ in your own code, which is one possible way to get stylesheet paths app-relative. Refer Tilde: Reference the Application Root


4.7 How can I reference simple DLL which contains one class but has no namespace assigned to it in an .aspx page?


You don't need a namespace to reference it; anything in the bin folder is implicitly in the same namespace as the page being compiled. So if your class looks like this:


Public Class MyClass1
Public Sub New()
End Sub

public Function getTheName(byval strval as string) as string
Return "Hello" + strval
End function
End Class


VB.NET


Dim mc As New MyClass1
Response.Write(mc.getTheName)


C#


MyClass1 mc = new MyClass1();
Response.Write(mc.getTheName);



4.8 How do I specify the Japanese locale for the controls in my Japanese localized page?


Just set the locale to Japanese in the Page directive.
i. e Set the Culture= "ja-JP" for the Page Directive.

  • ASP.NET pages support Culture and UICulture attributes to support independent localized pages.
  • Controls on pages can pick the culture of the page and can render culture-dependent content.

       


4.9 Why do some of the events on my page fire twice?


This is probably because you explicitly subscribed to the events in code and also specified the AutoEventWireUp of Page to true (it's true by default). If so, the Page_Load, for example, will be fired once for your event subscription and once because the Page subscribed it for you (by looking for a specific event handler method signature).

To avoid this turn off AutoEventWireUp or remove your subscription code.


4.10 How to remove the spaces in a given string?


Use the Namespace System.Text.RegularExpressions VB.NET


Dim strval As String = "Jack and Jill"
Dim strnewval As String = Regex.Replace(strval, " ", "")
Response.Write(strnewval)


C#


string strval = "Jack and Jill";
string strnewval = Regex.Replace(strval, " ", "");
Response.Write(strnewval)     ;




4.11 I get the error System.__ComObject when using recordset?


This error occurs if you are trying to fetch the recordset value as follows


rs.Fields("productname")



To avoid this error try VB.NET


rs.Fields("productname").Value.ToString()


C#


rs.Fields["productname").Value.ToString() ;



4.12 Why do I get error "A generic error occurred in GDI+." when trying to save the bitmap file?


May be the path of the file you are giving is wrong or you do not have write permissions on the specific folder.


4.13 How can I force a Save As dialog box from an ASP.NET Web page.


VB.NET


Response.Clear()
Response.AppendHeader("content-disposition", "attachment; filename=document1.doc")
Response.ContentType = "text/plain"
Response.WriteFile(Server.MapPath("document1.doc"))
Response.Flush()
Response.End()


C#


Response.Clear();
Response.AppendHeader("content-disposition", "attachment; filename=document1.doc");
Response.ContentType = "text/plain";
Response.WriteFile(Server.MapPath("document1.doc"));
Response.Flush();
Response.End();



4.14 In ASP.NET is there a control similar to Combobox in Windows forms?


Check out Andy Smith's ComboBox Control
Also an useful article by Khoi ComboBox WebControl


4.15 How to do text encryption and decryption?


Here are some interesting articles that talk about encryption and decryption:

 


4.16 How can I trigger a submit on my form when the enter key is pressed?


Add this to the body element:

 


<body MS_POSITIONING= "GridLayout"onkeypress="if(window.event.keyCode==13){ document.Form1.submit();}">
...
</body>


Also check out Andy Smith's DefaultButton Control which triggers submit selectively on one of many buttons based on the context.