Click here to Skip to main content
15,915,508 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Timer Problem Pin
Michael Sync3-Jan-08 21:38
Michael Sync3-Jan-08 21:38 
GeneralRe: Timer Problem Pin
N a v a n e e t h3-Jan-08 21:49
N a v a n e e t h3-Jan-08 21:49 
GeneralRe: Timer Problem Pin
Christian Graus3-Jan-08 23:26
protectorChristian Graus3-Jan-08 23:26 
Generaldropdown list Validator Pin
samerh3-Jan-08 20:25
samerh3-Jan-08 20:25 
GeneralRe: dropdown list Validator Pin
Michael Sync3-Jan-08 21:41
Michael Sync3-Jan-08 21:41 
GeneralRe: dropdown list Validator Pin
samerh3-Jan-08 22:59
samerh3-Jan-08 22:59 
AnswerRe: dropdown list Validator Pin
Sonia Gupta3-Jan-08 23:06
Sonia Gupta3-Jan-08 23:06 
GeneralRe: dropdown list Validator Pin
Michael Sync4-Jan-08 4:23
Michael Sync4-Jan-08 4:23 
I have tested. It works.. Can you try it again? Let's say there is one dropdownist and comparevalidator in your page. Set like that "ControlToValidate="DropDownList1"" and "ValueToCompare="All"" in CompareValidator.

<![CDATA[<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>]]>



<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:dropdownlist id="DropDownList1" runat="server" autopostback="True">
onselectedindexchanged="DropDownList1_SelectedIndexChanged"&gt;
</asp:dropdownlist>
<asp:comparevalidator id="CompareValidator1" runat="server" errormessage="CompareValidator">
ControlToValidate="DropDownList1" ValueToCompare="All"&gt;</asp:comparevalidator>
</div>

<asp:button id="Button1" runat="server" text="Button" />

</form>
</body>
</html>

Write the following code in Server-side. (Note that I used the arraylist in that sample. You can still use DDL instead of ArrayList.)

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections;
public partial class _Default : System.Web.UI.Page
{
ArrayList al = new ArrayList();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack) {
al.Add("All");
al.Add("Michael Sync");
al.Add("Nav");
al.Add("Dave");
al.Add("Toolbox");

DropDownList1.DataSource = al;
DropDownList1.DataBind();
}

}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) {

}
}

Run the webproject.. Select "Nav" and click "Button". then, you will get the error as the way it should be. And select "All" and click "button". there won't be any error. I hope this is what you want.

Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)


GeneralPreventing multiple clicks on a button. Pin
Janu_M3-Jan-08 20:12
Janu_M3-Jan-08 20:12 
GeneralRe: Preventing multiple clicks on a button. Pin
samerh3-Jan-08 20:28
samerh3-Jan-08 20:28 
GeneralRe: Preventing multiple clicks on a button. Pin
Janu_M3-Jan-08 21:27
Janu_M3-Jan-08 21:27 
GeneralRe: Preventing multiple clicks on a button. Pin
Michael Sync3-Jan-08 21:30
Michael Sync3-Jan-08 21:30 
GeneralRe: Preventing multiple clicks on a button. Pin
Declan Bright4-Jan-08 1:47
Declan Bright4-Jan-08 1:47 
Generalwant to fransfer datas from sql server to excel Pin
Deepthy.P.M3-Jan-08 20:08
Deepthy.P.M3-Jan-08 20:08 
GeneralRe: want to fransfer datas from sql server to excel Pin
kumareshTMC3-Jan-08 22:27
kumareshTMC3-Jan-08 22:27 
GeneralRe: want to fransfer datas from sql server to excel Pin
Deepthy.P.M4-Jan-08 1:42
Deepthy.P.M4-Jan-08 1:42 
GeneralDatabase Exception Pin
SreejithAchutan3-Jan-08 20:02
SreejithAchutan3-Jan-08 20:02 
GeneralRe: Database Exception Pin
Michael Sync3-Jan-08 20:08
Michael Sync3-Jan-08 20:08 
GeneralRe: Database Exception Pin
SreejithAchutan3-Jan-08 20:10
SreejithAchutan3-Jan-08 20:10 
GeneralRe: Database Exception Pin
Michael Sync3-Jan-08 20:50
Michael Sync3-Jan-08 20:50 
GeneralRe: Database Exception Pin
SreejithAchutan3-Jan-08 21:39
SreejithAchutan3-Jan-08 21:39 
GeneralRe: Database Exception Pin
Michael Sync3-Jan-08 21:54
Michael Sync3-Jan-08 21:54 
GeneralRe: Database Exception Pin
Paul Conrad4-Jan-08 6:52
professionalPaul Conrad4-Jan-08 6:52 
GeneralRe: Database Exception Pin
SreejithAchutan3-Jan-08 21:49
SreejithAchutan3-Jan-08 21:49 
GeneralRe: Database Exception Pin
SreejithAchutan3-Jan-08 22:28
SreejithAchutan3-Jan-08 22:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.