C# .NET - ICallbackEventHandler problem in Firefox

Asked By joker george on 18-Mar-09 11:56 PM

Hi,

I try to use ICallbackEventHandler in my webpage to get owner information and display. My code as below.

I do test on IE 6 and IE 7 and every thing work fine. However, when i test using firefox, it not return me any result.

I found that RaiseCallbackEvent is not fire when run debug in firefox, any one have any idea what i miss out?

Code in Page Load:

#region Asyn Postback for Get OwnerInformation

ownerTextBox.Attributes["onchange"] = "DoTheCallback(document.all." + ownerTextBox.ClientID + ".value,0);return true;";

string js = Page.ClientScript.GetCallbackEventReference(this, "arg", "ClientCallbackFunction", "context");

// Wrap it up in a nice function

System.Text.StringBuilder sb = new System.Text.StringBuilder();

sb.Append("function DoTheCallback(arg, context) {");

sb.Append(js);

sb.Append("; }");

// ...and register it.

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "DoTheCallback", sb.ToString(), true);

#endregion



Code in aspx page

<script type="text/javascript">

function ClientCallbackFunction(arg, ctx)

{

eval(arg);

}

function ClientErrorCallBack(arg)

{

alert("Error!: " + arg);

}

</script>

ICallbackEventHandler problem in Firefox

Sangeetha Ayyappan replied to joker george on 19-Mar-09 03:32 AM

Hi,

The problem is that document.all is not a valid property in FF. So replace the below line,

ownerTextBox.Attributes["onchange"] = "DoTheCallback(document.all." + ownerTextBox.ClientID + ".value,0);return true;";

To

ownerTextBox.Attributes["onchange"] = "DoTheCallback(document.all ? document.all. : document.getElementById( ' " + ownerTextBox.ClientID + ".value  + "document.all ? ' ' : ' ' ') " + ",0);return true;";

Cheers

READ THIS

C_A P replied to joker george on 19-Mar-09 03:36 AM
you do not cancel the default image postback. change code to:

Attributes["onclick"] = callbackRef + ";return false;";

TRY THIS LINK

C_A P replied to joker george on 19-Mar-09 03:38 AM
http://www.netnewsgroups.net/group/microsoft.public.dotnet.framework.aspnet/topic34155.aspx
thanks
joker george replied to Sangeetha Ayyappan on 19-Mar-09 04:09 AM

thanks a lot, really appreciate. You save my time, i already spent almost one day to trace the problem, but didnt notice on this.

Again. Thanks.

ICallbackEventHandler for multiple object
joker george replied to joker george on 19-Mar-09 10:55 PM

The sample i post before is for one control object in a webpage. If my webpage have few object i want to apply ICallbackEventHandler, how should i do this?

Example : The sample above is raisecallback event when ownerTextbox on change, if i want to raisecallback also when user select on locationdropdownlist and display other information (which totally no related to ownerTextbox), is it possible to do so?