Thursday, November 26, 2009

Auto wrapped in GridView ?


Using CSS as follows

word-wrap: break-word;
white-space: pre-wrap; /* css-3 */

white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */

white-space: -pre-wrap; /* Opera 4-6 */

white-space: -o-pre-wrap; /* Opera 7 */

word-wrap: break-word; /* Internet Explorer 5.5+ */

for more details follow below link

"http://community.sgdotnet.org/blogs/chuawenching/archive/2007/03/22/ASP.NET-2.0-Autowrapping-in-GridView--_2D00_-Is-that-possible_3F00_.aspx"

how to get dropdownlist selected value and text in javascript

var IndexValue = $get('<%=ddlGraphperiod.ClientID %>').selectedIndex;
var SelectedText = $get('<%=ddlGraphperiod.ClientID %>').options[IndexValue].text;
var SelectedVal = $get('<%=ddlGraphperiod.ClientID %>').options[IndexValue].value;

How to handle Enter Key on ASP.NET web page.

One of the most annoying things in developing web pages is handling the "Enter key" for form submission. Enter key has been the favourite way users like to submit forms. Though we provide Buttons to click on, the easiest and intuitive way is that, I can enter some text, make some changes and then hit "Enter" to accomplish my submission.

The defaultbutton property can be specified at the Form level in the form tag as well as at panel level in the definition tag. The form level setting is overridden when specified at the panel level, for those controls that are inside the panel.

for more details follow below link

"http://geekswithblogs.net/ranganh/archive/2006/04/12/74951.aspx"

How to Use space char in Enum datatype


Using description property. Implemented in Secure DTMS Application for Peak KVA parameter type Enum.
Use below link for more details.

"http://blog.spontaneouspublicity.com/2008/01/17/associating-strings-with-enums-in-c/"

How to use theme on button. How to apply css to command button.

first sol. is use skin but we have to create different skin for different button. Another sol is use css, keep in mind that set border width to 0px, and height and width to the button. Now the theme is ok but one more thing is which button should press on enter key for the same set submit button use SubmitBehavior property to true and set to false for other button.
1. show button press effect.
2. Press Enter Key will submit the page

How to make similar date format for our web site. Or how to make a website that will not depend on system datatime format.

using culture.
Set culture like Culture="en-GB".
We need not to set date format after using culture.

Vertical Label in ASP.NET


using CSS, We can make vertical label.
writing-mode: tb-rl;
filter: flipv fliph;

Empty Image Path Issue


Always set default path to every Image and linkbutton control otherwise they refer current path automatically.

How to call Server Side function using ajax in asp.net

Using Web method we can call server side method from java script.

Use following link for more details.

"http://69.10.233.10/KB/ajax/ajax_server_side_call.aspx?display=Print"

How to Set JS Path on Master Page for different level of content pages


1) Add a method in master page that include a script tag in header of page, like this: The two basic ways to solve this problem are:

Add a method in master page that include a script tag in header of page, like this:

private void addScriptInc(string path)
{
HtmlGenericControl script = new HtmlGenericControl(""script""); script.Attributes.Add(""type"", ""text/javascript""); script.Attributes.Add(""language"", ""javascript""); script.Attributes.Add(""src"", ResolveClientUrl(path)); Page.Header.Controls.Add(script);
}

or use the Page.ClientScript.RegisterClientScriptInclude method to add a script include inside body>form tags (i don't like this method)

2) Write the script tag like this:


The two solutions above can be used with other elements, like links, images, etc.

3) Register Script from server side.
String logOutJSPath = VirtualPathUtility.MakeRelative(Page.AppRelativeVirtualPath, ""~/JS/Logout.js"");
String logOut = """";
Page.ClientScript.RegisterStartupScript(this.GetType(), ""Logout"", logOut);"

How to disiable cut, copy, paste and selection operation in TextBox using JS.


use following inbuilt JS function.

oncut="return false"
oncopy="return false"
onpaste="return false"
oncontextmenu="return false"
onselectstart="return false"

How to prevent Insert Duplicate record into Database on Page Refersh.


Page_Load()
{
If(!Page.IsPostBack)
{
Session["update"] = Server.UrlEncode(DateTime.Now.Tostring();
}
}

Page_PreRender()
{
ViewState["update"].ToString() = ViewState["update"].Tostring();
}

SaveButton_Click()
{
If(Session["update"].Tostring() == ViewState["update"].Tostring());
{
-------------
-------
---
Session["update"] = Server.UrlEncode(DateTime.New.Tostring());
}
}

Navigation in Page using JS

Use "history.go(-1);return false;" to go back in browser based application.
"history.go(1);return false;" to go forward in browser based application.

How to preserve value at navigation time like on back button show previous selection.

Use Server.Transfer(url, true);
Wheres ture means Preservform value.