- Get Started
Let's create an html table that is showing some sample data. Here is it:
<table>
<tbody>
<tr>
<th>
Column1
</th>
<th>
Column2
</th>
</tr>
<tr>
<td>Data1.1</td>
<td>Data2.1</td>
</tr>
<tr>
<td>Data1.2</td>
<td>Data2.2</td>
</tr>
</tbody>
</table> - Let's Add some style to it
Let's add some simple styling to the table so it looks pretty! here is the css:
table{width:400px;border:solid 1px black;}
th {background:black;color:White;}
td {color:Black;} - Thinking about multiple styles of table
Let's add an id to table and change some things in our css to make it more
specific.
HTML:
<table id="my-table" class="my-table">
<tbody>
<tr>
<th>
Column1
</th>
<th>
Column2
</th>
</tr>
<tr>
<td>Data1.1</td>
<td>Data2.1</td>
</tr>
<tr>
<td>Data1.2</td>
<td>Data2.2</td>
</tr>
</tbody>
</table>
CSS:
#my-table{width:400px;border:solid 1px black;}
#my-table th {background:black;color:White;}
#my-table td {color:Black;} - Let's build another style
Let's add another style to table. So now css looks like following:
#my-table{width:400px;border:solid 1px black;}
#my-table th {background:black;color:White;}
#my-table td {color:Black;}
#my-table-gray{width:400px;border:solid 1px gray;}
#my-table-gray th {background:gray;color:White;}
#my-table-gray td {color:gray;} - Let's add jQuery to switch style!
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script>
jQuery(document).ready(
function() {
jQuery("a").click(function() {
var table = jQuery("#my-table")[0];
if (table.className == "my-table")
table.className = "my-table-gray";
else
table.className = "my-table";
});
}
);
</script>
http://picasaweb.google.com/lh/photo/4KmKLPYDYIwzFS6BbNOfmg?authkey=Gv1sRgCJ2FjqX7hqreRw&feat=directlink
Welcome to Prashant's blog
Dear Friends
I'm a Computer engineer and like to develop interesting things. Most of the time i love to post the things that make me in trouble when i'm doing my work. Code snippets are also included. You can request a code snippet, and Solution of your problem, or you can suggest blog topic. you can mail me at lakhlaniprashant+feedback at gmail.com to contact me.
I'm a Computer engineer and like to develop interesting things. Most of the time i love to post the things that make me in trouble when i'm doing my work. Code snippets are also included. You can request a code snippet, and Solution of your problem, or you can suggest blog topic. you can mail me at lakhlaniprashant+feedback at gmail.com to contact me.
Floow me on Twitter
Getting married? try FirstPhera.Com, Wedding planning portal for indians to provide wedding websites, GiftRegistry, Wedding Guide and much more
Find out more about me
Follow updates of this blog
Wednesday, November 11, 2009
jQuery How to build a simple table style switcher
Labels:
javascript,
JQUERY,
Tips and Tricks
| Reactions: |
CheckBoxList Required Validation in Javascript
ASP.NET CODE:
JAVASCRIPT CODE:
<asp:CheckBoxList ID="chkList" runat="server">
<asp:ListItem>Item One</asp:ListItem>
<asp:ListItem>Item two</asp:ListItem>
<asp:ListItem>Item three</asp:ListItem>
<asp:ListItem>Item four</asp:ListItem>
</asp:CheckBoxList>
<asp:Button ID="btnSubmit" runat="server" ValidationGroup="CHK" OnClientClick="return validateChk();" Text="Validate"/>
JAVASCRIPT CODE:
function validateChk() {
debugger;
var found = false;
var validated = false;
var id = document.getElementById("<%=chkList.ClientID %>").id;
var elements = document.forms[0].elements;
for (i = 0; i < elements.length; i++) {
if (elements[i].type == "checkbox" && elements[i].id.indexOf(id) > -1) {
found = true;
if (elements[i].checked) {
validated = true;
break;
}
}
}
if (found && validated)
return true;
else
return false;
}
Labels:
ASP.NET,
Javascript Code Snippets
| Reactions: |
Tuesday, November 3, 2009
Using single ClientValidationFunction for similar validations using custom validator
Here is an example of how to write a common client validation function while using similar kind of validations on more than one asp.net control.
This example is showing how to validate two drop down list using a single javascript function for required
ASP.NET Markup
Javascript client validation function:
This example is showing how to validate two drop down list using a single javascript function for required
ASP.NET Markup
<asp:DropDownList ID="ddlCountry" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlCountry_SelectedIndexChanged" CausesValidation="false">
</asp:DropDownList>
<asp:CustomValidator ID="cvCountry" runat="server" ControlToValidate="ddlCountry"
EnableClientScript="true" ValidationGroup="REG" Display="None" ErrorMessage="Country is required" Text=" "
ClientValidationFunction="validateCbo"></asp:CustomValidator>
<asp:DropDownList ID="ddlState" runat="server">
</asp:DropDownList>
<asp:CustomValidator ID="cvState" runat="server" ControlToValidate="ddlState"
EnableClientScript="true" ValidationGroup="REG" Display="None" ErrorMessage="State is required" Text=" "
ClientValidationFunction="validateCbo"></asp:CustomValidator>
Javascript client validation function:
function validateCbo(source, args) {
var ddl = null;
if(source.controltovalidate.indexOf('Country')>-1)
ddl = document.getElementById('<%=ddlCountry.ClientID %>');
else
ddl = document.getElementById('<%=ddlState.ClientID %>');
if (ddl != null) {
args.IsValid = !(ddl.options[ddl.selectedIndex].value == 0);
}
else
args.IsValid = true;
}
| Reactions: |
Sunday, November 1, 2009
DotNetNuke 5.x with .net framework 2.0 (web.config)
Everybody, who tried to deploy DotNetNuke 5.x on web servers that is not having .net framework 3.5 requires changes to web.config. You can download this web.config which worked for me.
Hope this helps :)
Hope this helps :)
Labels:
DotNetNuke,
DotNetNuke 5.0,
Tips and Tricks
| Reactions: |
Sunday, October 11, 2009
DotNetNuke - Login control not working!
Some time ago, Somebody emailed me regarding his strange problem. The dnn live website was throwing error and was not able to redirect to login page! So I asked him to login in host acount and uninstall openId authentication provider, because that's the dll that was causing proble. He was staring at and after some time he said, I'm getting error while logging in man!
I laughed a little and give following suggession:
Create a page Sample.aspx which inharits from DotNetNetNuke.Framework.Pagebase and in page load manually authenticate a user host using UserController.ValidateUser method. That will help you login to the site in host account and then delete the page one you are done.
So these kind of problems where host or admin user cannot login with their accounts can be solved by this simple sample page. But be remember to change the host password because we have to use that password in clear format to write the code. Here is the code that I used:
I laughed a little and give following suggession:
Create a page Sample.aspx which inharits from DotNetNetNuke.Framework.Pagebase and in page load manually authenticate a user host using UserController.ValidateUser method. That will help you login to the site in host account and then delete the page one you are done.
So these kind of problems where host or admin user cannot login with their accounts can be solved by this simple sample page. But be remember to change the host password because we have to use that password in clear format to write the code. Here is the code that I used:
'Imports DotNetNuke.Security.Membership
Dim loginStatus As UserLoginStatus = UserLoginStatus.LOGIN_FAILURE
UserController.ValidateUser(PortalSettings.PortalId, "host", "xxx", PortalSettings.PortalName, "", PortalSettings.PortalName, AuthenticationLoginBase.GetIPAddress(), loginStatus)
Response.Redirect(NavigateUrl(PortalSettings.HomeTabId))
Wednesday, September 16, 2009
Writing smart DotNetNuke Schedulers that sends email
This post is for those who are using dotnetnuke scheduler for rapidly sending emails to the users. There are times when scheduler fails to complete the job and try running the job again base on retry setting applied to it. Bad news is that, the user who are expecting the email once receives the email twice. If you set retry frequency to an hour or so, and your code meets some bad data like null reference of so, users will get the email every hour.
This description at least clears the thing that we should at least not set retry frequency while sending emails through scheduler. Next thing comes to mind is, there should be a batter way to do it. I personally work on it and think about some way that adds some overhead to the scheduler activity but makes sure that no user will get the same email more than once.
Create a table called tracker that stores following things:
Id - Auto increment
Email - Email sent
Type - default 0, increment it in case if you are using more than one scheduler for sending emails
Date - Small date time that stores date and time the email sent to this user.
The next step is to modify your query to return email that are not in this table. For Example:
Select userid, email
from users u
where email not in (select email from tracker where u.email = tracker.email and convert(varchar(10),date,112) = convert(varchar(10),getdate(),112))
(Please be careful while comparing dates and times in t-sql. If you are using small date time to compare two dates, equality is base on date and time both.)
I think using this trick will never send email to the same user again.
Have fun with your development.
This description at least clears the thing that we should at least not set retry frequency while sending emails through scheduler. Next thing comes to mind is, there should be a batter way to do it. I personally work on it and think about some way that adds some overhead to the scheduler activity but makes sure that no user will get the same email more than once.
Create a table called tracker that stores following things:
Id - Auto increment
Email - Email sent
Type - default 0, increment it in case if you are using more than one scheduler for sending emails
Date - Small date time that stores date and time the email sent to this user.
The next step is to modify your query to return email that are not in this table. For Example:
Select userid, email
from users u
where email not in (select email from tracker where u.email = tracker.email and convert(varchar(10),date,112) = convert(varchar(10),getdate(),112))
(Please be careful while comparing dates and times in t-sql. If you are using small date time to compare two dates, equality is base on date and time both.)
I think using this trick will never send email to the same user again.
Have fun with your development.
Wednesday, September 9, 2009
DotNetNuke: Creating a new parent portal in localhost
As we all know, dotnetnuke provides a to build a multiportal environment using a single dotnetnuke installation and I was doing that exercise in order to get that running in localhost.
So let's start building a new parent portal in local environment:
Hope you enjoyed this trick.
So let's start building a new parent portal in local environment:
- Login to host and go to Host > Portals
- Click Create New Portal
- Enter portalName Parent1 and username parent1admin, and add all other required data.
- go ahead an create new portal.
- Create a new virtual directory Parent1 and point it to dnn installation that you are using to create this portal
- Go to Host > Sql and execute this query :
UPDATE PortalAlias
Set HTTPAlias = 'localhost/Parent1'
Where HTTPAlias='Parent1' or HTTPAlias='parent1' - Try accessing localhost/parent1
Hope you enjoyed this trick.
Subscribe to:
Posts (Atom)
