If you have ever tried to change the master page, programmatically, for your content page in the Page_load and you find it doesn’t work – try doing it in the page’s Page_PreInit event. It should work just fine.
Category Archives: Tips
Update only a Content Page and not a Master Page in ASP.NET
try to use BlendTrans just like FireFox does
put this code on <HEAD> tag in the masterpage
<meta http-equiv=”Page-Enter” content=”blendTrans(Duration=0)”/>
<meta http-equiv=”Page-Exit” content=”blendTrans(Duration=0)”/>
iĀ hope haveĀ helped…
BY LAKSHMIPRASATH@GMAIL.COM
Multiple Stylesheets in Themes
Many of you may not know this, but you can have multiple stylesheets within a theme.
Let’s say you have a lot of styles, and you’d like to categorize them in some way – maybe typestyles, layouts or colors. What you can do is have 3 separate stylesheets within one theme, categorized in whichever way you’d like.
But watch out – there’s one ‘gotcha’. The names of the stylesheets be alphabetical in the filesystem, and therefore, will be addressed sequentially, based on the alphabetical position in the filesystem. So – be careful. If you have one style for TD in a stylesheet in a low alphabetical position, and then you have another style TD style in a higher alphabetical position, the TD style in the higher alphabetical stylesheet will be used, overriding the stylesheet in the lower alphabetical position.
Display Particular Format for Phone Number
Let’s say your database stores phone numbers without the dashes or parentheses, but you would like to display it like that, on the web page.
To do this, store the number as an integer, and then, the following code snippet will do the trick:
Dim s as integer="1234567891"label1.text=string.Format("{0:(000)000-0000}",s)
Can a website run without a web.config file?
Yes. A website can run without a web.config file. At that time it will read configuration info from machine.config
Difference between Convert.ToInt32(string) and Int32.Parse
Convert.ToInt32(string) and Int32.Parse(string) yield identical results except when the string is actually a null. In this case, Int32.Parse(null) throws an ArgumentNullException; but, Convert.ToInt32(null) returns a zero. So it is better to use Int32.Parse(string)
Difference between two dates in C#
public int GetTotalDays(DateTime startedDateTime)
{
//get the current date
DateTime nowDate = System.DateTime.Now;
//use timespan to get the number of days
System.TimeSpan span = nowDate – startedDateTime;
int days = (int)span.TotalDays;
return days;
}
How to use ASP.Net control in Javascript
Let’s say you have a textbox (ASP.Net control) named:
‘txtFirstName’
To be able to use the ID in your Javascript functions, you can do something like this:
var txtbox = document.getElementById(‘<%=txtFirstName.ClientID%>’);
Then, you can use the variable ‘txtBox’ throughout your Javascript function, with the normal Javascript attributes (txtbox.value, txtbox.disabled, etc)
On Button click check-uncheck all checkboxes
<script language=”javascript” type=”text/javascript”>
function Select(Select)
{
for (var n=0; n < document.forms[0].length; n++)
if (document.forms[0].elements[n].type==”checkbox”)
document.forms[0].elements[n].checked=Select;
return false;
}
</script>
onClientclick=”javascript:Select(true)”
GroupBox in ASP.Net
To get the same results in ASP.Net as Winforms for a GroupBox (header/group text, along with a rounded-corner border), just use an ASP.Net panel, and use the GroupingText property.
<asp:Panel ID="Panel1" runat="server" GroupingText="My Group"></asp:Panel>