KuruviDotNet






   

<< June 2017 >>
Sun Mon Tue Wed Thu Fri Sat
 01 02 03
04 05 06 07 08 09 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30


This page is for documenting my experiences with DotNet. Practical problems that I faced and solutions I found. -Pradeep Kumar


Contact Me

If you want to be updated on this weblog Enter your email here:


rss feed

Friday, March 19, 2004
Changing the Properties of The Body Tag Programatically in WebForm


Declare the body tag element as a HtmlGenericControl as below
protected System.Web.UI.HtmlControls.HtmlGenericControl bodyTag;

Then you can add attributes to the body tag by using the syntax

bodyTag.Attributes.Add("bgcolor","#CCCCCC"); // This will set the body
bgcolor to be grey

That should do what you need.


Reference:
Discussions in ASP.NET

Posted at 08:32 pm by tpkx
Make a comment

Thursday, March 18, 2004
Injecting Client Side Scripts From Server

You can pass client side scripts from the ASP.NET server app by calling


-This will popup a MsgBox front of the browser window.


-This will popup a print dialog in the one which comes when you goto File->Print in IE.


Posted at 06:44 am by tpkx
Make a comment

Selected Value Property of DropDownList Control

We developers coming from an ASP background find ASP.NET a bliss, especially after seeing nice functionality such as the selected value property of the DropDownList Control.

Frequently in web development we come across situations when values are dynamically loaded into a dropdownbox from a DB and a particular item has to be preselected programatically. This was done in a tedious manner by iterating through all the items in dropdownlist and comparing the listitem value's to the value what we want it to be selected and if it matches make the selected property to be true.

Phew! Along Came ASP.NET In ASP.NET the beauty the above functionality can be achieved by simply setting the selectedValue property to the value in the dropdown you want to be selected and freow it is done!! For example you have a set of departments in the DB with dept. code,dept. description for each.

Load these departments into dropdown as
Dim dbconn As New MySqlConnection(connStr)
dbconn.Open()
Dim cmdfetch As New MySqlCommand("SELECT * FROM dept_master", dbconn)
dbreader = cmdfetch.ExecuteReader
drpDept.DataSource = dbreader
drpDept.DataTextField = "DEPT_DESC"
drpDept.DataValueField = "DEPT_CODE"
drpDept.DataBind()
dbreader.Close()
dbconn.Close()


After that If the dept codes are like 100,101,102 ... I can select the department in the dropdown with value 101 as drpDept.SelectedValue = 101 and it gets selected. :-) Note: The selected value property is supported only in .NET framework1.1 dbconn.Dispose()

Posted at 06:39 am by tpkx
Make a comment

Tuesday, March 09, 2004
Using Required Field Validator to validate dropdown box selections

A typical Dropdown will have a default "Select" listitem as the first item in the DropDown. The users will have to select some other listitem in the dropdown to proceed. They should not be allowed to proceed without making a selection in the dropdown. For these purposes the RequiredFieldValidator link can be used. But the validator won't throw an error as the default item "Select" has some value like 0 or -1. Solution: Set the InitialValue Property of the Required Field validator to "0" or -1  the default ListItem value and now the required field validator will function as required.

Posted at 11:33 pm by tpkx
Make a comment

Printing From an ASP.NET Page, Injecting Client Side Script

This injects a client side script for popping up the windows print dialog.

Posted at 09:19 pm by tpkx
Comments (1)

Previous Page

Next Page