Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
natebell  
#1 Posted : Wednesday, June 13, 2007 9:54:54 PM(UTC)
natebell

Rank: Member

Groups: Member
Joined: 3/28/2007(UTC)
Posts: 56

when I press the the cancel all changes button, it gives me the confirmation popup twice. I'm not sure where to put my debug statement because the only line of code I am executing in the cancel button function is to clear the EditingOptions

Thanks,

Nate

Dmitry  
#2 Posted : Thursday, June 14, 2007 6:11:29 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
Hello,

"Cancel all changes" functionality is implemented in PhotoEditorSample. Please, install PhotoEditorSample (it is included into installation package) and review how it works. If you will have some questions - feel free to contact us.

Sincerely yours,

Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!

natebell  
#3 Posted : Thursday, June 28, 2007 11:46:50 PM(UTC)
natebell

Rank: Member

Groups: Member
Joined: 3/28/2007(UTC)
Posts: 56

to solve this problem I changed the butShow and butRestore back to regular Button controls. for some reason when I had changed it to a LinkButton control it then showed the message twice, if there is a fix for this that would be great as it allows me greater control of the style of the buttons, but for now I'm just going back to the regular Button controls.
Sergey Peshekhonov  
#4 Posted : Monday, July 2, 2007 12:57:55 PM(UTC)
Sergey Peshekhonov

Rank: Advanced Member

Groups:
Joined: 6/5/2007(UTC)
Posts: 57

Hello, Nate.

I found that "BODY's OnBeforeUnload fires twice in IE" is known bug. For example you can see this page:

http://www.dbforums.com/showthr....php?page=2&t=622842.

When ASP.NET renders page, it creates following Html code for LinkButton:

Code:
<a href="__doPostBack('PhotoEditorSample1$butRestore','');" ... ></a>

So, when you click the link in IE, IE fires onbeforeunload twice: firstly when meet href="", secondly during execution of __doPostBack.

To eliminate this you may use the following workaround: try to add # into href of A element. This way IE will interprete it as link to part of current page and will not call onbeforeunload event.

To use LinkButtons into your project you should do the following:

(I explain getting PhotoEditorSample.ascx as source for changes)

Changes in PhotoEditorSample.ascx:

1. Replace <asp:Button with <asp:LinkButton

2. Remove from <asp:LinkButton ID="butRestore" OnClick property.

Changes in Default.aspx:

1. Change Button to LinkButton into OnInit method.

Changes in PhotoEditorSample.ascx.cs:

1. Add following string to OnInit method:

Code:
butRestore.OnClientClick = "this.href = '#';if (this.disabled) return false;__doPostBack('" + butRestore.UniqueID+ "','');return false;";

Edited by user Tuesday, December 18, 2007 3:02:39 AM(UTC)  | Reason: Not specified

Sincerely yours,

Sergey Peshekhonov.

Aurigma Technical Support Team.

natebell  
#5 Posted : Monday, July 2, 2007 10:00:11 PM(UTC)
natebell

Rank: Member

Groups: Member
Joined: 3/28/2007(UTC)
Posts: 56

Sergey,

that worked great! Thanks for the tip as well, it can help in other .NET projects.

one extra thing I needed to do, I needed to move the code for the butRestore_Click event from PhotoEditorSample.ascx.cs to Default.aspx.cs(or my page which is different)

I'm using the following code:

Code:
	protected void butRestore_Click(object sender, EventArgs e)
	{
		Aurigma.PhotoEditor.PhotoEditorController PhotoEditorController1 = 
			(Aurigma.PhotoEditor.PhotoEditorController)PhotoEditorSample1.FindControl("PhotoEditorController1");
		PhotoEditorController1.EditingOptions = "";
	}

i had to use FindControl to get to the controller object

thanks,

Nate

Edited by user Tuesday, December 18, 2007 3:02:22 AM(UTC)  | Reason: Not specified

Sergey Peshekhonov  
#6 Posted : Tuesday, July 3, 2007 4:19:20 PM(UTC)
Sergey Peshekhonov

Rank: Advanced Member

Groups:
Joined: 6/5/2007(UTC)
Posts: 57

Hello, Nate!

As I understand, you just want to get rid of using FindControl function on your page.

To do this you should add the following property to PhotoEditorSample.ascx.cs:

Code:
public Aurigma.PhotoEditor.PhotoEditorController PhotoEditorController
{
    get
    {
         return PhotoEditorController1;
    }
}

This way you will get possibility to use the following code on your page (for example Default.aspx)

Code:
protected void butRestore_Click(object sender, EventArgs e)
{
    PhotoEditorSample1.PhotoEditorController.EditingOptions = "";
}

To add handler to butRestore.Click event we use this code in Default.aspx:

Code:
protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    ((Button)PhotoEditorSample1.FindControl("butRestore")).Click += 
        new EventHandler(butRestore_Click);
    ((Button)PhotoEditorSample1.FindControl("butShow")).Click +=
        new EventHandler(butShow_Click);	
}

Edited by user Tuesday, December 18, 2007 3:03:02 AM(UTC)  | Reason: Not specified

Sincerely yours,

Sergey Peshekhonov.

Aurigma Technical Support Team.

natebell  
#7 Posted : Wednesday, July 4, 2007 9:33:49 PM(UTC)
natebell

Rank: Member

Groups: Member
Joined: 3/28/2007(UTC)
Posts: 56

yeah i just don't like FindControl because it is not type safe/strong

thanks for the tip!

natebell  
#8 Posted : Friday, July 20, 2007 7:14:39 AM(UTC)
natebell

Rank: Member

Groups: Member
Joined: 3/28/2007(UTC)
Posts: 56

Sergey,

I'm having some trouble with Firefox. It seems that the fix we did in this previous post isn't working for them.

It seems that when you have disabled="disabled" in the html, which doesn't validate, doesn't correspond to the check we're doing in the onclick event (e.g. if(this.disabled) ) for Firefox, I've tried using alert(this.disabled) and it is showing "undefined".

I've even tried to set an add_load method to fix it in script, but it hasn't worked, maybe you can help.

here is what I tried:

Code:
//fix for firefox and/or other standards compliant browsers
//if disabled is checked for in script it needs to be set in script
var el = document.getElementById("<%= saveButton.ClientID %>");
if(el)el.disabled=<%= (!saveButton.Enabled).ToString().ToLower() %>;

the result is that I'm getting an error when I click a disabled button in FireFox:

Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that aruments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

thanks,

Nate

Edited by user Tuesday, December 18, 2007 3:03:25 AM(UTC)  | Reason: Not specified

natebell  
#9 Posted : Monday, July 23, 2007 10:26:35 PM(UTC)
natebell

Rank: Member

Groups: Member
Joined: 3/28/2007(UTC)
Posts: 56

were you able to reproduce this behavior in FireFox?
natebell  
#10 Posted : Wednesday, July 25, 2007 12:27:22 AM(UTC)
natebell

Rank: Member

Groups: Member
Joined: 3/28/2007(UTC)
Posts: 56

Sergey,

To fix this I just set the onclick for a disabled button simply to "return false;" That way if it is disabled it never fires anything.

this seems to be working, but I still have one issue I'll start as a new topic

Sergey Peshekhonov  
#11 Posted : Wednesday, July 25, 2007 9:00:15 PM(UTC)
Sergey Peshekhonov

Rank: Advanced Member

Groups:
Joined: 6/5/2007(UTC)
Posts: 57

Nate,

I have reproduced the problem with disabled buttons, so I get the same error when I click on disabled LinkButton.

As I understand you have solved this problem for you. But I will post my appreciation in hope that this will be helpful.

All we need is just cancelling click event on disabled elements. So, I have wrapped this elements with div and disabled bubbling of click event if it occurs on disabled element.

To apply my solution you should do the following:

1. Replace in PhotoEditorSample.ascx the following:

Code:
<div class="PhotoEditorButtons">
    <asp:Button runat="server" ID="butRestore" CssClass="PhotoEditorRestoreButton" OnClick="butRestore_Click" meta:resourcekey="butRestoreResource1" />
    <asp:Button runat="server" ID="butShow" CssClass="PhotoEditorShowButton" meta:resourcekey="butShowResource1" />
</div>

with:

Code:
<div class="PhotoEditorButtons">
    <asp:LinkButton runat="server" ID="butRestore" CssClass="PhotoEditorRestoreButton" meta:resourcekey="butRestoreResource1" />
    <asp:LinkButton runat="server" ID="butShow" CssClass="PhotoEditorShowButton" meta:resourcekey="butShowResource1" />
    <asp:LinkButton runat="server" ID="saveButton" OnClick="saveButton_Click" Text="Save something" />
</div>

and this:

Code:
// WORKAROUND for disabled elements in IE.
// Using Ms.Ajax we get exception on disabled input element.
// To prevent it we disable bubbling of events.
if (Sys.Browser.agent == Sys.Browser.InternetExplorer) {
    butRestore.parentNode.onmouseup =
    butRestore.parentNode.onclick = function()
    {
        if (butShow != window.event.srcElement) {
            window.event.cancelBubble = true; 
        }
    };
}
with:

Code:
// WORKAROUND for disabled elements in IE.
// Using Ms.Ajax we get exception on disabled input element.
// To prevent it we disable bubbling of events.
if (Sys.Browser.agent == Sys.Browser.InternetExplorer) {
    butRestore.parentNode.onmouseup =
    butRestore.parentNode.onclick = function()
    {
        if (((window.event.srcElement == butRestore) && (butRestore.disabled)) ||
            ((window.event.srcElement == saveButton) && (saveButton.disabled))) {
            window.event.cancelBubble = true;
        }
    };
}

2. Add at the end of PhotoEditorSample.ascx the following.

Code:
<script>
Sys.Application.add_load(function(e, t) {
    if (t.get_isPartialLoad()) return;
    var saveButton = document.getElementById(<% = "\"" + saveButton.ClientID + "\"" %>);
    saveButton.disabled = true;
    // or
    // saveButton.disabled = false;
)};
</script>

3. Change Button to LinkButton in OnInit method in the Default.aspx.cs file.

4. Add the following string in OnInit method in the PhotoEditorSample.ascx.cs file:

Code:
saveButton.OnClientClick = "this.href = '#';if (this.disabled) return false; try { __doPostBack('" + saveButton.UniqueID + "',''); } catch (e) {} return false;";

5. Add the following function to the end of PhotoEditorSample class in PhotoEditorSample.ascx.cs file:

Code:
protected void saveButton_Click(object sender, EventArgs e)
{
    // Some saving functionality.
}

Edited by user Tuesday, December 18, 2007 3:03:28 AM(UTC)  | Reason: Not specified

Sincerely yours,

Sergey Peshekhonov.

Aurigma Technical Support Team.

natebell  
#12 Posted : Wednesday, July 25, 2007 9:39:41 PM(UTC)
natebell

Rank: Member

Groups: Member
Joined: 3/28/2007(UTC)
Posts: 56

great, thanks for this help Sergey, I'll probably apply this as it seems like a better fix.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.