Feeds:
Posts
Comments

Archive for the ‘Asp.Net’ Category

In my aspx page I have several CheckBoxList and the requirement is client side validation for all the CheckBoxList in the page before page submission.
As CheckListBox do not support Required Validator we need to user Custom Validator for this validation.

Here is the sample of my ASPX code

<div>
<asp:CheckBoxList runat=”server” ID=”chkList1″>
<asp:ListItem Text=”List Item 1_1″ Value=”11″></asp:ListItem>
<asp:ListItem Text=”List Item 1_2″ Value=”12″></asp:ListItem>
</asp:CheckBoxList>

<asp:CustomValidator ID=”validator_chkList1″ ClientValidationFunction=”ValidateCheckList” runat=”server”>*Select at least one item</asp:CustomValidator>

<asp:CheckBoxList runat=”server” ID=”chkList2″>
<asp:ListItem Text=”List Item 2_1″ Value=”21″></asp:ListItem>
<asp:ListItem Text=”Lsit Item 2_2″ Value=”22″></asp:ListItem>
</asp:CheckBoxList>
<asp:CustomValidator ID=”validator_chkList2″ ClientValidationFunction=”ValidateCheckList” runat=”server”>*Select at least one item</asp:CustomValidator>

<asp:Button runat=”server” ID=”btnSubmit” onclick=”btnSubmit_Click” />
</div>

&nbsp;

I used the following javascript to do the validation

function ValidateCheckList(sender, args) {
var chkControlId = sender.id.replace("validator_", "");
alert(chkControlId);
var options = document.getElementById(chkControlId).getElementsByTagName('input');
var ischecked = false;
args.IsValid = false;
for (i = 0; i < options.length; i++) {
var opt = options[i];
if (opt.type == "checkbox") {
if (opt.checked) {
ischecked = true;
args.IsValid = true;
}
}
}
}

Nice and easy trick but it took around two hours for me to figure out, that’s why sharing.
Happy coding. 🙂

Read Full Post »

Recently I have written a article which shows the power of WPF UI Automation. This library is really rich and make UI Automation easier.

Here is the article : Automate software using WPF UI Automation

Read Full Post »

Recently I developed a web application which calls many services and loads a lot of data in every page with a lot of calculation in the background from the database, so the site became slower. Then I start searching Google to find out a good solution and got some real good ideas to improve my web application’s performance. Here, in this article, I am shared the tips I applied in the application to improve performance and it really works fine now.

http://www.codeproject.com/KB/aspnet/aspnetPerformance.aspx

Read Full Post »

I needed to access every cell of a GridView in Client Side in one of my application, so needed to call javascript from GridView Cell. Actually I have a Dropdownlist , select any of the item from the dropdownlist will change the value of the same row in a different cell and will change the GridView footer row  value.

Here is a article showing how to access row and cell of a gridview from client site.
http://weblogs.asp.net/ashrafurrahaman/archive/2009/02/26/javascript-for-gridview-row-level.aspx

Read Full Post »

I needed to run my web application in a fixed port of my web server due to fixed SiteURL in the web site whcih I needed to change every time from the web config.

Here are simple and easy steps tp run your web application in a fixed port of your web server.

1. Go to Solution Explorer of your project
2. Go to properties of your web site clicking F4 on your web site name.
3. Make “Use Dynamic Port” to “False” and put a “Port Number“, you website will always run in that port number.

Read Full Post »

Sometime for big solutions really feel pain to see IDE is perfoming slower. And sometime i need to work from home using remote dersktop of my office. Remote desktop got slower if at the same time get IDE slower too then no way to work. So searched in the internet and got some good solutios. Now really can work faster. Sharing some of the tip

1. web.config should not have <compilation batch=”false” />
2. Turn off AutoToolboxPopulate (Tools -> Options -> Windows Forms Designer set AutoToolboxPopulate False)
3. Turn off Track Active item (Tools -> Options -> Projects and Solutions uncheck Track Active Item in Solution Explorer)
4. Disable Navigation Bar(Tools -> Options -> Text Editor -> C#, uncheck Navigation bar)
5. Move file in App_Code into a class library project
6. Disable validation Options for HTML Editing (Tools -> Options -> Validation -> Clear show error checkbox)

-Hope you are working faster now

Read Full Post »