Button click event fires after two time click

7 views
Skip to first unread message

Sunny

unread,
Aug 28, 2008, 7:43:45 PM8/28/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
G'day,

Here I have little problem with button click event fires after every
two click.

I have asp.net website and have 3 buttons generated dynamically on
page through a loop based on different access level permissions.

Following is a little code snippet attached. This code is a part of a
loop, Loop basically check the folders through the main and plus the
user access set in database. In simple term every single folder access
has been set in database and loop is going through the different level
of folder and check the folder path with the one stored in database
and if that matches it will check the access level (like giving user
group access to different user groups for this folder or folder rename
or folder remove)

//change your action tab code here,, as per the requirement
if (this._mBARUser)
{
ImageButton btnUserAccess = new
ImageButton();
btnUserAccess.ID =
btnUserAccess.UniqueID;
btnUserAccess.EnableViewState =
true;
btnUserAccess.ImageUrl =
@"App_Share/images/AccessMini.jpg";
btnUserAccess.ImageAlign =
ImageAlign.AbsMiddle;
btnUserAccess.Height =
Unit.Parse("20px");
btnUserAccess.Width =
Unit.Parse("20px");
btnUserAccess.CommandName =
Application["RootFolder"].ToString().Trim() + _mSFolder.Trim() + @"\"
+ svrDirs[i].Name;
btnUserAccess.Click += new
ImageClickEventHandler(btnUserAccess_Click);
btnUserAccess.ToolTip = "Set User
Access";
btnUserAccess.EnableViewState =
true;

y.Controls.Add(btnUserAccess);
}

if (this._mBRemove)
{
// please change following code in
regards to removing folder
// and change the image as well.
ImageButton btnFolderRemove = new
ImageButton();
btnFolderRemove.ID =
btnFolderRemove.UniqueID;
btnFolderRemove.EnableViewState =
true;
btnFolderRemove.ImageUrl =
@"App_Share/images/DeleteMini.jpg";
btnFolderRemove.ImageAlign =
ImageAlign.AbsMiddle;
btnFolderRemove.Height =
Unit.Parse("20px");
btnFolderRemove.Width =
Unit.Parse("20px");
btnFolderRemove.CommandName =
Application["RootFolder"].ToString().Trim() + _mSFolder.Trim() + @"\"
+ svrDirs[i].Name;

btnFolderRemove.Attributes.Add("onclick", "return confirm_delete();");
btnFolderRemove.ToolTip = "Remove
Folder";
btnFolderRemove.EnableViewState =
true;

btnFolderRemove.Click +=new
ImageClickEventHandler(btnFolderRemove_Click);


y.Controls.Add(btnFolderRemove);
}


if (this._mBRename)
{
// please change following code in
regards to removing folder
// and change the image as well.
ImageButton btnFolderRename = new
ImageButton();
btnFolderRename.ID =
btnFolderRename.UniqueID;
btnFolderRename.EnableViewState =
true;
btnFolderRename.ImageUrl =
@"App_Share/images/RenamePenMini.jpg";
btnFolderRename.ImageAlign =
ImageAlign.AbsMiddle;
btnFolderRename.Height =
Unit.Parse("20px");
btnFolderRename.Width =
Unit.Parse("20px");
btnFolderRename.CommandName =
Application["RootFolder"].ToString().Trim() + _mSFolder.Trim() + @"\"
+ svrDirs[i].Name;
btnFolderRename.CommandArgument =
"1";
btnFolderRename.EnableViewState =
true;

btnFolderRename.Click += new
ImageClickEventHandler(btnFolderRename_Click);

btnFolderRename.ToolTip = "Rename
Folder";

y.Controls.Add(btnFolderRename);
}


Now the problem.
=============

Problem strats when it comes to handling those dynamic button click
events. Everytime when I click button it seems it goes to client side
javascript (attached to one of the button just to check the response
from the user like delete or not) but it does not do anything. To run
the button click event successfully I have to click the same button
twice.

Need little help for this.

Thanks,
Sunny

Cerebrus

unread,
Aug 29, 2008, 12:36:00 AM8/29/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
It's possible that the first click cancels out because the client
event handler does not return a true value. And in the same vein, the
second click manages to return a true value (because some global
variable has been set earlier).

But I'm just guessing ! ;-)

Glenn

unread,
Aug 29, 2008, 7:00:48 AM8/29/08
to DotNetDe...@googlegroups.com
It sounds like the control that captures the event is not in focus.  The first click gets the focus and the second click is the one that actually gets processed.
 
Been there, had that happen.
 
...Glenn

Sunny

unread,
Aug 31, 2008, 10:07:16 PM8/31/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Cerebrus,

I think the first click event does not cancels out as I have put a
small javascript function calling in one of the button click event
and it does fire, plus the button guid event generation has also been
done (as one of the button actually creates different guid for
different
items on page) the only thing is when it comes to do some work as
Delete or add or rename folder it seems it does not work.

Glenn,

I am quite not sure with your pov as i said earlier if the event is
not in focus then how come the script registered through that event
(with that
javascript function in it) can fire itself successfully but the code
after that like delete, add or rename does not work.

Need little more detailed help,, please
Sunny
> > But I'm just guessing ! ;-)- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages