[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Abraham Andres Luna

11/14/2006 3:16:00 PM

hello everyone,

i am trying to set the defaultbutton property and i get the following error:

The DefaultButton of '' must be the ID of a control of type IButtonControl.


so i guess instead of this class declaration:

using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IS.WebControls
{
public class ISBaseButton : Button
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
this.CssClass = "frmbtn";
}
}
}


i need this one:

using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IS.WebControls
{
public class ISBaseButton : WebControl, IButtonControl,
IPostBackEventHandler
{
private bool blCausesValidation = false;
private string strCommandArgument = "";
private string strCommandName = "";
private string strPostBackUrl = "";
private string strText = "";
private string strValidationGroup = "";

protected override void OnInit(EventArgs e)
{
base.OnInit(e);
this.CssClass = "frmbtn";
}

bool IButtonControl.CausesValidation
{
get
{
return blCausesValidation;
}
set
{
blCausesValidation = value;
}
}

string IButtonControl.CommandArgument
{
get
{
return strCommandArgument;
}
set
{
strCommandArgument = value;
}
}

string IButtonControl.CommandName
{
get
{
return strCommandName;
}
set
{
strCommandName = value;
}
}

string IButtonControl.PostBackUrl
{
get
{
return strPostBackUrl;
}
set
{
strPostBackUrl = value;
}
}

string IButtonControl.Text
{
get
{
return strText;
}
set
{
strText = value;
}
}

string IButtonControl.ValidationGroup
{
get
{
return strValidationGroup;
}
set
{
strValidationGroup = value;
}
}

public void IButtonControl.Click(Object Sender, EventHandler E)
{
//
}
}
}


so that the defaultbutton property can work. i need help in declaring the
IButtonControl.Click and the IButtonControl.Command event. everything i have
tried fails, and i've searched the internet for examples and have found
nothing that works.

so far i've tried:

EventHandler IButtonControl.Click(Object Sender, EventArgs E)
{
//
}


and many others.


thanks for your help.


1 Answer

Teemu Keiski

11/19/2006 7:48:00 PM

0

Hi,

Button base class already implements IButtonControl, so you shouldn't need
to reimplement the interface. Wth your ISBaseButton you could use:

<form id="form1" runat="server" defaultbutton="Button1" >
....
<cc:ISBaseButton ID="Button1" runat="server" />

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice....

"Abraham Andres Luna" <brag1518@hotmail.com> wrote in message
news:eg7LO$$BHHA.996@TK2MSFTNGP02.phx.gbl...
> hello everyone,
>
> i am trying to set the defaultbutton property and i get the following
> error:
>
> The DefaultButton of '' must be the ID of a control of type
> IButtonControl.
>
>
> so i guess instead of this class declaration:
>
> using System;
> using System.Web.UI;
> using System.Web.UI.WebControls;
>
> namespace IS.WebControls
> {
> public class ISBaseButton : Button
> {
> protected override void OnInit(EventArgs e)
> {
> base.OnInit(e);
> this.CssClass = "frmbtn";
> }
> }
> }
>
>
> i need this one:
>
> using System;
> using System.Web.UI;
> using System.Web.UI.WebControls;
>
> namespace IS.WebControls
> {
> public class ISBaseButton : WebControl, IButtonControl,
> IPostBackEventHandler
> {
> private bool blCausesValidation = false;
> private string strCommandArgument = "";
> private string strCommandName = "";
> private string strPostBackUrl = "";
> private string strText = "";
> private string strValidationGroup = "";
>
> protected override void OnInit(EventArgs e)
> {
> base.OnInit(e);
> this.CssClass = "frmbtn";
> }
>
> bool IButtonControl.CausesValidation
> {
> get
> {
> return blCausesValidation;
> }
> set
> {
> blCausesValidation = value;
> }
> }
>
> string IButtonControl.CommandArgument
> {
> get
> {
> return strCommandArgument;
> }
> set
> {
> strCommandArgument = value;
> }
> }
>
> string IButtonControl.CommandName
> {
> get
> {
> return strCommandName;
> }
> set
> {
> strCommandName = value;
> }
> }
>
> string IButtonControl.PostBackUrl
> {
> get
> {
> return strPostBackUrl;
> }
> set
> {
> strPostBackUrl = value;
> }
> }
>
> string IButtonControl.Text
> {
> get
> {
> return strText;
> }
> set
> {
> strText = value;
> }
> }
>
> string IButtonControl.ValidationGroup
> {
> get
> {
> return strValidationGroup;
> }
> set
> {
> strValidationGroup = value;
> }
> }
>
> public void IButtonControl.Click(Object Sender, EventHandler E)
> {
> //
> }
> }
> }
>
>
> so that the defaultbutton property can work. i need help in declaring the
> IButtonControl.Click and the IButtonControl.Command event. everything i
> have
> tried fails, and i've searched the internet for examples and have found
> nothing that works.
>
> so far i've tried:
>
> EventHandler IButtonControl.Click(Object Sender, EventArgs E)
> {
> //
> }
>
>
> and many others.
>
>
> thanks for your help.
>
>