D
Daniel
I've created a custom control including some Literal ( constructed
with html markup) and an ImageButton firing event ( add a vote ).
public event VoteCommandEventHandler VoteCommand;
protected override void CreateChildControls()
{
LiteralControl ltrBeforeVote = new
LiteralControl(buildMarkupBeforeVoteButton());
this.Controls.Add(ltrBeforeVote );
btnVote = new ImageButton();
btnVote.ImageUrl =
this.Page.ClientScript.GetWebResourceUrl(typeof(UnPourTous.MyWebControl.Article),
"UnPourTous.Resources.plus.jpg");
btnVote.Style["border-width"] = "0px";
btnVote.Style["position"] = "absolute";
btnVote.Style["right"] = "5px";
btnVote.Style["top"] = "2px";
btnVote.Attributes["onClick"] =
Page.ClientScript.GetPostBackEventReference(this, "vote");
this.Controls.Add(btnVote);
LiteralControl ltrAfterVote = new
LiteralControl(buildMarkupAfterVoteButton());
this.Controls.Add(ltrAfterVote );
}
public virtual void RaisePostBackEvent(string eventArgument)
{
switch (eventArgument)
{
case "vote":
if (VoteCommand != null)
VoteCommand(this, new
VoteCommandEventArgs(ArticleID));
break;
case "commentaire":
if (CommentCommand != null)
CommentCommand(this, new
CommentCommandEventArgs(ArticleID));
break;
}
}
This custom control is instanciated many times and each instance added
to a panel control's list.
Instanciation occurs in the page OnLoad event
The panel appears once in the main aspx page.
In the container page an eventhandler is registered to listen to the
VoteCommand fired by the PostBackEvent.
Everytime the button is clicked, a vote is normaly added to a
database.
But my problem is that the event is fired twice. Two votes are added
to the database.
It seems that an other event is firing after the button click.
Thanks in advance...!
with html markup) and an ImageButton firing event ( add a vote ).
public event VoteCommandEventHandler VoteCommand;
protected override void CreateChildControls()
{
LiteralControl ltrBeforeVote = new
LiteralControl(buildMarkupBeforeVoteButton());
this.Controls.Add(ltrBeforeVote );
btnVote = new ImageButton();
btnVote.ImageUrl =
this.Page.ClientScript.GetWebResourceUrl(typeof(UnPourTous.MyWebControl.Article),
"UnPourTous.Resources.plus.jpg");
btnVote.Style["border-width"] = "0px";
btnVote.Style["position"] = "absolute";
btnVote.Style["right"] = "5px";
btnVote.Style["top"] = "2px";
btnVote.Attributes["onClick"] =
Page.ClientScript.GetPostBackEventReference(this, "vote");
this.Controls.Add(btnVote);
LiteralControl ltrAfterVote = new
LiteralControl(buildMarkupAfterVoteButton());
this.Controls.Add(ltrAfterVote );
}
public virtual void RaisePostBackEvent(string eventArgument)
{
switch (eventArgument)
{
case "vote":
if (VoteCommand != null)
VoteCommand(this, new
VoteCommandEventArgs(ArticleID));
break;
case "commentaire":
if (CommentCommand != null)
CommentCommand(this, new
CommentCommandEventArgs(ArticleID));
break;
}
}
This custom control is instanciated many times and each instance added
to a panel control's list.
Instanciation occurs in the page OnLoad event
The panel appears once in the main aspx page.
In the container page an eventhandler is registered to listen to the
VoteCommand fired by the PostBackEvent.
Everytime the button is clicked, a vote is normaly added to a
database.
But my problem is that the event is fired twice. Two votes are added
to the database.
It seems that an other event is firing after the button click.
Thanks in advance...!