:: 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

11. Client Side Scripting

FAQ Home
   11.1 How to emit client-side javascript blocks from VB.NET/C#?
   11.2 How to open a new Window using javascript function from a Link button?
   11.3 Is there a JavaScript Quick Reference Guide?
   11.4 How to set the background color of a web page using code behind?
   11.5 How to resolve error message "String constants must end with a double quote."?
   11.6 Why can't I open a new browser window from within server code?
   11.7 How to get the confirmation of Yes/No from a javascript pop-up and display the value on the page?
   11.8 How to open a browser window with maximum size on click of a button?
   11.9 How can I know if the client browser supports active scripting?
   11.10 How to determine if the Browser supports javascript?
   11.11 How can I change the scroll bar color?
   11.12 How to create dynamic javascripts in server side code based on server side variables?
   11.13 How can I use a Timer Control to refresh a page automatically at a specified interval?
   11.14 How to open a new window without IE menus and toolbars on click of a button?
   11.15 Does JavaScript support hashtables/ hash tables or dictionary type data structures?
   11.16 How to disable the right click option on a web page?
   11.17 How to hide a control using javascript?
   11.18 Can I modify WebUIValidation.js?
   11.19 How to change a Label element's text in javascript?
   11.20 How to resize two <div> tags on a webform?
   11.21 How to check/ uncheck a checkbox based on the text entered in textbox?
   11.22 How to rotate a Label Text?
   11.23 How to display a message in the status bar of a browser window?
   11.24 How to change the BackGroundColor of a page based on the value selected in a DropdownList?
   11.25 How to disable a Dropdownlist once someone has selected an item in the Dropdownlist?
   11.26 How can I make a Textbox a mandatory field if a checkbox is checked on a button click event in the client side?
   11.27 Why does the SmartNavigation does not work on the live server but works perfectly on the Development Machine?
   11.28 How to pop up a message box when no item in the dropdownlist is selected before postback?
   11.29 Are there any resources regarding the Mozilla specific Browser Objects and CSS information?



11.1 How to emit client-side javascript blocks from VB.NET/C#?


The RegisterStartupScript method emits the script just before the closing tag of the Page object's <form runat= server> element.

VB.NET


RegisterStartupScript("Sample", "<SCRIPT Language='javascript'>alert('Hello World');</SCRIPT>")


C#


RegisterStartupScript("Sample", "<SCRIPT Language='javascript'>alert('Hello World');</SCRIPT>");


Alternatively, use the RegisterClientScriptBlock method which emits the client-side script just after the opening tag of the Page object's <form runat= server> element.


11.2 How to open a new Window using javascript function from a Link button?


VB.NET


link.Attributes( "onClick" ) = "window.open( 'url', 'name', 'properties' )";


C#


link.Attributes[ "onClick" ] = "window.open( 'url', 'name', 'properties' )";


You can also check out Andy Smith's RemoteWindow Control


11.3 Is there a JavaScript Quick Reference Guide?


Here is a JavaScript Quick Reference Guide in Poster Format that you can print out and refer easily. Covers the older and newer version of DOM and IE and Mozilla.
Danny Goodman's JavaScript and Browser Objects Quick Reference


11.4 How to set the background color of a web page using code behind?


Yes

  1. In the body tag, add runat="server" and give the tag an id (e.g. id="bodyID").
  2. In the class definition in the code-behind, add VB.NET

     


Protected bodyID As System.Web.UI.HtmlControls.HtmlGenericControl


C#


protected System.Web.UI.HtmlControls.HtmlGenericControl bodyID ;


In code, use the attributes collection to set the bgcolor attribute: VB.NET

 


bodyID.Attributes.Add("bgcolor", "green")


C#


bodyID.Attributes.Add("bgcolor", "green");



11.5 How to resolve error message "String constants must end with a double quote."?


To resolve this check out PRB: The Tag Is Treated As a Closing Tag When Inside a Quoted String


11.6 Why can't I open a new browser window from within server code?


Server code executes on Server, whereas the new window is created on the client. You need to use client-side script to open new window.


11.7 How to get the confirmation of Yes/No from a javascript pop-up and display the value on the page?


Code Behind


Button1.Attributes.Add("onclick", "getMessage()")


Client Side


<SCRIPT language=javascript>
function getMessage()
{
var ans;
ans=window.confirm('Is it your confirmation.....?');

if (ans==true)
     {
          document.Form1.hdnbox.value='Yes';
     }
else
     {
          document.Form1.hdnbox.value='No';}
     }
</SCRIPT>


To display the Yes/No value selected by user, in your code behind file:


Response.Write(Request.Form("hdnbox"))



11.8 How to open a browser window with maximum size on click of a button?


VB.NET


Button1.Attributes.Add("onclick", "window.open('page2.aspx','','fullscreen=yes')")


C#


Button1.Attributes.Add("onclick", "window.open('page2.aspx','','fullscreen=yes')");



11.9 How can I know if the client browser supports active scripting?


You can detect and interept the capabilities of your client using the namespace System.Web.HttpBrowserCapabilities :
VB.NET


Dim browser As System.Web.HttpBrowserCapabilities = Request.Browser
Response.Write("Support ActiveXControl: " + browser.ActiveXControls.ToString())


C#


System.Web.HttpBrowserCapabilities browser = Request.Browser;
Response.Write ("Support ActiveXControl: " + browser.ActiveXControls.ToString ());


For more details Refer: Detecting Browser Types in Web Forms


11.10 How to determine if the Browser supports javascript?


VB.NET


if Page.Request.Browser.JavaScript then
...
else
...
end if


C#


if (Page.Request.Browser.JavaScript )
{
...
}
else
{
...
}



11.11 How can I change the scroll bar color?


Use Style Sheet to change the color of scroll-bar


body
{
FONT-SIZE: 8pt;
COLOR: #000000;
background-color: #EEEEEE;
scrollbar-face-color: #EEEE99;
scrollbar-highlight-color: #DDDDDD;
scrollbar-shadow-color: #DEE3E7;
scrollbar-3dlight-color: #FF6600;
scrollbar-arrow-color: #006699;
scrollbar-track-color: #EFEFEF;
scrollbar-darkshadow-color: #98AAB1;
}



11.12 How to create dynamic javascripts in server side code based on server side variables?


Here's and example:

VB.NET


Dim value As String = "pic1.jpg"
Button1.Attributes("onMouseOver") = "alert( '" + value + "');"


C#


string value = "pic1.jpg";
Button1.Attributes["onMouseOver"] = "alert( \"" + value + "\");" ;



11.13 How can I use a Timer Control to refresh a page automatically at a specified interval?



<asp:DropDownList id="DropDownList1" runat="server" onChange="SetClientRefresh(this);">
     <asp:ListItem Value="1000">1 second</asp:ListItem>
     <asp:ListItem Value="2000">2 seconds</asp:ListItem>
     <asp:ListItem Value="3000">3 seconds</asp:ListItem>
</asp:DropDownList>



<script language='javascript'>
var cTimeOut = null;
function SetClientRefresh(sel)
{
     var newRefresh = sel.options[sel.selectedIndex].value;
     if (cTimeOut != null)
     {
          window.clearTimeout(cTimeOut);
     }
     cTimeOut = window.setTimeout("ReLoadPage()", newRefresh);
}

function ReLoadPage()
{
     window.location.reload();
}
</script>



11.14 How to open a new window without IE menus and toolbars on click of a button?


VB.NET


Button2 .Attributes.Add ("onclick", "window.open('webform1.aspx','_blank','toolbar=no')")


C#


Button2 .Attributes.Add ("onclick", "window.open('webform1.aspx','_blank','toolbar=no')");