Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Wednesday, March 28, 2012

Accessing Wizard controls from client-side Javascript

Hello, all. Thank you in advance for taking the time to read this. I know it is of questionable relevance given that the Wizard control is not an AJAX toolbox component, but since the Wizard is more useless without AJAX, I am hoping it is close enough to topic.

I am dealing with a Viewstate issue that is forcing me to use ScriptingServices for most of my async communications in order to keep round-trip bandwidth manageable. I want to be able to validate entries made on a long wizard both on-the-fly and at-once. But using ScriptServices, I need to access the values in the Wizard controls from client-side.

Trouble is, I have found that the wizard controls and their values are only visible to the DOM if the wizard page is active. Elements on non-active pages are totally inaccessible from client-side.

For example, a textbox with ID=TextBox1 is on page 1 of the wizard control ID=Wizard1; ID=TextBox2 is on page 2 of Wizard1

when Wizard1.ActiveStepIndex equates to page 1, then $get("TextBox1") works, but $get("TextBox2") does not.

I am assuming that there is some object reference to Wizard1 that can be used client-side to get the values from control on non-active pages, but I just can't seem to find it.

If anyone has experience with this and can tell me how to access these values, I would be highly appreciative.

Thank you again for the time, and in advance for any information you can provide.

Hi,

That's because only content of active step will be rendered. Though, all of them will be encoded and saved in ViewState.

My suggestion is use hiddenFields out of the wizard to keep the value of different steps, and they will be always generated and persisted.


Thanks again for your time and thoughts. That's exactly how I have decided to handle it. It sure adds a lot of complication to what seemed like a pretty easy control. Add to it that I am replacing long dropdown lists with static values after a selection has been made to trim the viewstate, and I think it would have been easier to start from scratch.

The hidden fields work great -- very good idea.

Thanks again!

Accessing the pages server controls during webmethod calback

Hi,

Tell me please, when we call a webmethod during a callback, we send parameters through the javascript and dom to the webmethod on the server, right?

What if on the server I want, not only to access parameters sent from the javascript calling function, but I also want to acccess controls of the page, like other controls that didnt request the callback, like a gridview control or asp:textbox control, controls that re located on the page but that have nothing to do with the callback call.

Thanks a lot for your help.

PageMethods are static methods and have no access to controls on the page. However the client-side callback can access the DOM.

Accessing server-side Datatable object from client-side javascript?

I am working on a control that generates 2D charts (line,bar,pie,etc) using VML (for now) to draw the charts client-side. I am new to Javascript and still cant figure out how to access the data I need to graph from the javascript side. I am currently using a Sys.Data.Datable on the client side as test data (building the table manually in javascript) and it works fine but I cannot figure how to pass a datatable from the server to the control extension behavior?

I have read/seen code on the forums on how to do this using a web-service but I am really looking at a more generic approach where people could just bind a datatable to the control via the properties or in code so they can use their business logic layer functionality without having to write web-services.

Let's say I have the name of the page object/variable holding the datatable (from properties of control) how would I access this object as a Sys.Data.Datatable in Javascript? Would I need to use some kind of converter?

(hope I explained myself correctly and this makes sense to someone hehe)

Thanks in Advance

Pascal

Hello Pascal:

> I am new to Javascript and still cant figure out how to access the data I need to graph from the javascript side.

Strictly speaking, you can't! It is the server-side code that renders client-side code, so what you can do is actually the reverse: write the datatable to javascript.

Here is a topic that can give some hints:http://forums.asp.net/thread/1285185.aspx

This said, please feel free to go deeper with your question if needed.

-LV


Thanks for the quick reply btw :)

Here is some example of what I am trying to do (not actual code):

Lets say I have some ASPX page code like...

<script language="VB"> Private sub Page_Load() dim myTable as System.Data.Datatable ... populate table ... End sub</script><html> <body> <atlas:ScriptManager runat="server" ID="PageScriptManager" EnablePartialRendering="True"> </atlas:ScriptManager> <asp:Panel ID="ChartPanel" runat="server" Height="300" Width="400" /> <cc1:ChartPanelExtender ID="ChartPanelExtender1" runat="server" > <cc1:ChartPanelProperties ChartTitle="This is my Graph!" TargetControlID="ChartPanel" ChartType="0" ChartHeight="100" ChartWidth="300" ChartBackColor="#FF3A00" ChartTitleFontFamily="Arial Black" ChartTitleFontSize="20" ChartTitleFontWeight="Normal" ChartTitleTextAlign="Right" /> </cc1:ChartPanelExtender> </body></html>

The ChartPanelExtender is an atlas control extender that has its functionality (chart graphing) in its ChartPanelBehavior.js javascript file. What I would like to do is access that myTable from inside the javascript behavior file? Is that possible?

Thanks in advance,

Pascal

accessing javascript from code behind

Hello,

Ok, heres my scenario:

On the Client Side - I have a javascript event that populates a variable with a new value from an embeded activex control.

On the Server Side - I have a dataview that hooked to a database.

Desired Result - When the javascript event fires I need to pass the value of the changed variable to the server via a callback or something and populate the dataview based on the value received.

I know how to callback to the server on client event but My question is how do I access or pass that javascript value to the server? (Better yet does anybody know how to access a com object embeded in the browser from C#?)

I thought this would be easy but I just can't figure it out.

Thanks, Justin.

If I can gather what your saying, all you need to do is add runat="server" and an ID to whatever control you want and you can access it serverside. What most people do is add it to a hidden input, set that in javascript, and then access it via its ID in c#.

<input type="hidden" runat="server" id="theValue" />

theValue.Value = "Hello";


Create a hidden field on the page. Then from the client side JavaScript populate the hidden field with the value from the ActiveX control. You can then refer the value of the hidden field in the .CS file.

Let me know if you need a code example.


Thanks for the replies.


Hi...

I am using a code as below but getng an error saying hdClientUTC undefined evnthough i declared tht can any one help me. I want to get the content of offset variable in my C# code.

HtmlInputHidden hdClientUTC;

ClientScript.RegisterStartupScript(this.GetType(),"MyScript","<Script for=" +"window" +" " +"event=" +"onload" +" " +"language=" +"jscript" +">" +" var now = new Date(); var offset = now.getTimezoneOffset(); alert(offset); hdClientUTC.Value = offset; document.Form1.submit(); " +"</Script>");

Accessing inherited behavior properties

Hello,

I've created a new extender who's behavior class in the javascript file inherits from an existing control (in this case the cascading drop down) and registered it like so:

CustomCascadingDropDown.CustomCascadingDropDownBehavior.registerClass(
'CustomCascadingDropDown.CustomCascadingDropDownBehavior', AjaxControlToolkit.CascadingDropDownBehavior
);

I'm listening for the selectedValue property change event to occur so that I can access the resulting value and operate on it but when I try to access it from my inherited behavior class as this._selectedValue I get a null value. If I try using the callBaseMethod method to access the property accessor I get a different exception. How do I access inherited properties?

Also, what is the correct procedure for attaching to property changed events? I assumed from other posts that is by using this.add_propertyChanged(handler) but is this correct? How does this attach itself to a specific property or does it just enumerate through all properties that have been changed?

Thanks in advance.

Hi,

can I see the code that you're using to handle the event?


Sure thing... thanks for the help by the way.

The code below is just a test. I just want to see if I can access the inherited property.

First I attach a handler to listen for the property changed event in the initialize method of my custom behavior:

initialize : function() {
PersistentCascadingDropDown.PersistentCascadingDropDownBehavior.callBaseMethod(this, 'initialize');
this.add_propertyChanged(this.test);
},

Again, I'm not sure if this is the correct way to attach a handler to the propertyChanged event. It is only an assumption (how exactly do I target only one of the many properties that raise propertyChanged events?).

Next is my event handling method.

test : function (sender, args)
{
if (args._propertyName == "SelectedValue")
{
// Throws an exception
alert(PersistentCascadingDropDown.PersistentCascadingDropDownBehavior.callBaseMethod(this, 'get_SelectedValue'));

// Alerts as undefined
alert(typeof(this.get_SelectedValue));

// Alerts that object doesn't support method
alert(this.get_SelectedValue());
}
},

Thanks again for your help.

Accessing Guid returned from WebService in Javascript

Hi, I have read through the forum posts and looked in the 'QuickStart' documentation but I am still stuck: How can one read the value of a System.Guid passed back to Javascript?

I have a WebService:
[WebMethod][XmlInclude (typeof(System.Guid))]
public Guid WebLogin(string UserID, string Password) {

Which I call, via Atlas, from JavaScript:
function LogIn(UserID, Pwd) {
K2.WebService.Connection.WebLogin(UserID, Pwd, LogInResult);
}

function LogInResult(result) {
debugger
alert (result);
} ...

I cannot access the value of 'result' (which will be a System.Guid). We used to use the old WebService.htc - where one could access 'result.value' and read the value as a string. I have tried adding the [XmlInclude typeof(System.Guid))], which a forum post hinted at, but nothing was added to the /js as a result.

Thanks in advance for any help you are able to provide.

kangaloosh.ps:

I have used the JSON.stringify() at www.json.org to look inside 'result' and it is empty. Have I got to create a converter class on the server side? If so is there a source code sample somewhere?

Thanks again.

I think a custom converter would be needed to make Guids work, since they don't have any properties that can be automatically serialized to Javascript. But the simplest solution is probably just to change your web method to return the Guid as a string.

How are you planning to use the Guid on the client?


Thanks for the speedy reply;

Will write a string based WebService wrapper for the existing WebMethod (as it is already in use from thick clients).

kangaloosh
Yes, that should work. Please let me know if it doesn't.

Accessing DropShadow properties through javascript

I am have trouble accessing the properties of a drop shadow through javascript. My dropshadow looks like this

<asp:Panel runat="server" id="registeredusersTab"></asp:Panel>
<atlasToolkit:DropShadowExtender id="dsregisteredusersTab" runat="server">
<atlasToolkit:DropShadowProperties targetcontrolid="registeredusersTab" opacity="0" rounded="false" trackposition="true">
</atlasToolkit:DropShadowProperties
And I'm trying to use the following script on click of another link...
<script>
$object('dsregisteredusersTab').set_Opacity(0);
</script
Its basically can't find dsregisteredusersTab. Any help would be greatly appreciated...

You need an ID on the properties object itself, not the extender. Check out the DropShadow sample page for an example of this:

<asp:Panel runat="server" id="registeredusersTab"></asp:Panel>
<atlasToolkit:DropShadowExtender id="dsregisteredusersTab" runat="server">
<atlasToolkit:DropShadowProperties targetcontrolid="registeredusersTab" opacity="0" rounded="false" trackposition="true"ID="dsBehavior">
</atlasToolkit:DropShadowProperties>

...

<script>
$object('dsBehavior').set_Opacity(0);
</script>


Thanks

Accessing controls in a tab control using javascript

Hi ,

Im my project im using tab control.I wat to access the controls inside the content template using javascript.

How is this done?

Anyone please help.

Thanks n regards

Prathibha

prathibhaa:

Im my project im using tab control.I wat to access the controls inside the content template using javascript.

You need to know the client id of the control you want to access. You can get the client id of the control using the ClientID property.

Then in javascript you do this

document.getElementById(<id of control>) to get reference to the control


i tried it.

I have a textbox "txtEmpCode" placed in the content template of tab control.then i tried to access it as follows

document.getElementById("txtEmpCode")

But im getting null value


prathibhaa:

I have a textbox "txtEmpCode" placed in the content template of tab control.then i tried to access it as follows

document.getElementById("txtEmpCode")

Because the text box is in the tab control it may get a different client ID. Best way to check is to view the HTML source on the rendered page and look for the exact ID.

Alternatively you can go textbox.ClientID to get the client rendered ID of the text box control.


i tried this code

document.getElementById("<%=txtEmpCode.ClientID%>")

But I am getting an exception

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Description:Anunhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about theerror and where it originated in the code.

Exception Details:System.Web.HttpException:The Controls collection cannot be modified because the control containscode blocks (i.e. <% ... %>).

Source Error:

An unhandled exception was generated during the execution of thecurrent web request. Information regarding the origin and location ofthe exception can be identified using the exception stack trace below.


Stack Trace:

[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
System.Web.UI.ControlCollection.Add(Control child) +127
AjaxControlToolkit.ScriptObjectBuilder.RegisterCssReferences(Control control) in d:\E\AjaxTk-AjaxControlToolkit\Release\AjaxControlToolkit\ExtenderBase\ScriptObjectBuilder.cs:293
AjaxControlToolkit.ScriptControlBase.OnLoad(EventArgs e) in d:\E\AjaxTk-AjaxControlToolkit\Release\AjaxControlToolkit\ExtenderBase\ScriptControlBase.cs:260
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Control.LoadRecursive() +158
System.Web.UI.Control.LoadRecursive() +158
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3036

Please help

Thanks and regards

prathibha


prathibhaa:

i tried this code

document.getElementById("<%=txtEmpCode.ClientID%>")

But I am getting an exception

Where are you adding that code to?

You can always just inject the javascript doing this

StringBuilder sb =new StringBuilder();sb.Append("function getTextBox()");sb.Append("{");sb.Append("var textbox;");sb.Append("textbox = document.getElementById();");sb.Append("return textbox;");sb.Append("}");ClientScript.RegisterClientScriptBlock(this.GetType(),"mytextboxscript", sb.ToString());//now you have a javascript function that returns the textbox




Hi Prathibha,

prathibhaa:

document.getElementById("<%=txtEmpCode.ClientID%>")

But I am getting an exception

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

That's because you put the document.getElementById("<%=txtEmpCode.ClientID%>") in the wrong position. For example,

<head id="Head1" runat="server">
<title>Untitled Page</title>
<script type="text/javascript" language="javascript">
function getName(){

var labelValue = "<%=Label1.ClientID %>";
}
</script>
</head>

<body>
You will get the same error. So you should put it at the end of your form(or other proper position). By the way, you can use$get instead of document.getElementById() if you have added a ScriptManager before. They are the same but is much terser.

Best regards,

Jonathan


hi Jonathan,

Thank you.

can u please tell me where i have to give the javascript and how?

i got the javascript correctly when i gave the client id directly.

regards

Prathibha

Accessing Controls From JavaScript

What is the syntax for accessing control form javascript? I can't seem to find it anywhere - I thought it was something like

dunction HideOne(n)

{

var ele = Sys($(n))

}

not a lot to go on with what you have provided but...

assuming that "n" in this context is the id of an element you want to "access" or get then you should use "$(n)"
to avoid issues with that statement... in your example you would remove the Sys() part and only have the $(n) part

this all depends on, however, how you are creating your elements. if you are using the xml-script declarative approach then you might be better off using the $object() function.
the $object() function searches the current markup context for the element, then traverses the tree up to the Application level to try to find the element.
this is different than the $() function which is nothing more than a shortcut for "document.getElementById()"

this allows the ATLAS runtime to have (or support) multiple elements with the same "id" without violating the HTML 4.1 specifications stating "an elements id must be unique" which it clearly would be (in the current context)

hope that helps... if not try adding some more of your code so we can get a better understanding of what you are dealing with


That was perfect thanks.

Accessing control extender behaviors in javascript

Hi there,

I'm using the AJAX 1.0 Beta 2 extensions and the AjaxControlToolkit. I'm finding it extremely hard to access the behaviors associated with a given control. (I'd like to hook into the expandComplete event of an CollapsiblePanel).

I've tried using the following:

var cp = $get('IdOfMyCollapsiblePanel');
cp.get_behaviors()[0].add_expandComplete(MyHandlerFunction);

This results in an error with the get_behaviors() call.

Can anyone post an example of how to hook up a javascript method to an extenders event? (client-side)

I'd really appreciate it!

Jeremy

And here I go replying to myself...

I found the source of my problem. I was trying to set up the event handling in the pageLoaded event that is raised by the PageRequestManager, but the behaviors are not yet loaded at this time. Instead I hooked the Sys.Application.load event and everything works!

Jeremy

Monday, March 26, 2012

Accessing a WebService-Method

Hello, i was migrating from Atlas July-CTP to Beta 2.

Now get an error when i call my webservice from javascript and the message is talking about System.InvalidOepration and authentication failed,

but only when I mark the corresponding method with EnableSession= true. In Atals JulyCTP the same call worked fine. Is there maybe a change in security-model?

Did I forget something or a declarartion is not set right?

Can anybody explain?

Hallo Michael,

can you show us the code of youre WebService definition?

Servus
Klaus


Check to see if your Web service definition has the ScriptService attribute (http://ajax.asp.net/docs/mref/8bb8cdde-6050-e492-e72a-eed2242c213c.aspx).
I believe the CTP version didn't have this attribute.


using System;

using System.IO;

using System.Web;

using System.Collections;

using System.Collections.Generic;

using System.Threading;

using System.Web.Services;

using System.Web.Services.Protocols;

using System.Xml.Serialization;

using System.Web.UI.WebControls;

using Microsoft.Web.Script.Services;

[ScriptService]

[WebService(Namespace ="http://tempuri.org/")]

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

publicclass VehicleDataService : System.Web.Services.WebService

{

This Method is accessible, because it's called from Ajax:AutoCompleteExtender

[WebMethod(EnableSession =true)]

publicstring[] GetColors(string prefixText,int count)

{

string[] autoCompleteColors =null;

//Ablauf analog zu oben lediglich für Color statt für Model/Manufacturer

User user = SessionData.User;

if (autoCompleteColors ==null)

{

autoCompleteColors = VehicleDataUtils.GetColorsAsStringList(user);

}

int index =Array.BinarySearch(

autoCompleteColors, prefixText,

newCaseInsensitiveComparer());

if (index <0)

{

index = ~index;

}

int matchingCount;

for (matchingCount =0; matchingCount < count

&& index + matchingCount < autoCompleteColors.Length; matchingCount++)

{

if (!autoCompleteColors[index + matchingCount].StartsWith(

prefixText,StringComparison.CurrentCultureIgnoreCase))

{

break;

}

}

String[] returnValue =newstring[matchingCount];

if (matchingCount >0)

{

Array.Copy(autoCompleteColors, index, returnValue,0, matchingCount);

}

return returnValue;

}

This method is'nt accessible, it's called from pure javascript in a javascript-source file.

///<summary>

/// Setzt den aktuellen Hersteller (Name)

///</summary>

///<param name="input">Name des Herstellers</param>

[ScriptMethod]

[WebMethod(EnableSession =true)]

publicvoid SetActualManufacturer(string input)

{

SessionData.VehiclePageManufacturer = input;

}

}


Hello Michael,

maybe i'm wrong, but for me is VOID in a webservice a "not so god idee". You get absolut no response from this methode. It's not better to create an object with a returnvalue and react to the returnvalue?

It's only a idee.


The web service code seems OK. I don't know exactly how you're invoking the web service.
As you described, probably you don't have an aspx page with service reference configured using this web service. Adding a service reference to your page, makes AJAX download or include in the web page the proxy code (depending on the parameters you provide).
Check the proxy code that your service generates and see if it helps you (you can check that looking athttp://yourserverver/yourService.asmx/js - you just include /js after your web service address).

HTH,

Maíra

Access Session in WebMethod

I am trying to access the Session from an ATLAS WebMethod. My session is always equal to null. I am calling the method from javascript. How do I access the session?

[WebMethod]

publicbool DoStuff()

{

if (Session["Data"] !=null)

{

}

Thanks

You need to use [WebMethod(true)] to enable the session from that web method.

Access Denied javascript error - Urgent help required

Hi there,

I'm tearing my hair out here, i'm using the ModalPopupExtender and it's returning a javascript error "Access is denied"

It works perfectly on my machine locally but when uploaded to our production server it returns this error.

I know what you're thinking, it's cross-domain issue or iframes. However we don't use either!!!! I've searching the internet high and low to no avail.

I've even tried using scriptpath instead and that doesn't work either, get js error 'ajaxcontrolkit is undefined'

I'm going to have to scrap a lot of work if i can't get a solution for this.

Please, please help!

Thanks in advance

Rob

Have you identified the offending line with a debugger?


Hi David, It's a javascript error, simply one that is displayed by Internet Explorer 7, Line No. 5960Char: 49Error: Access is deniedCode: 0URL: xxxAny ideas?

A debugger like Firebug (for Firefox) will let you set a breakpoint there and see what the problem might be.

Access denied Error

HI,

I am getting an Access denied error, if I use AJAX in ASPX page..

intially I got Javascript window ( Do you wish to debug..) When I said 'Yes' it showed me the code below..

//------------------
// Copyright (C) Microsoft Corporation. All rights reserved.
//------------------
// MicrosoftAjax.js
Function.__typeName="Function";Function.__class=true;Function.createCallback=..................
........................
g=e.screenLeft-top.screenLeft-top.document.documentElement.scrollLeft+2 ------ its showing error at this point..

What is the solution for this?

Thanks


Try to disable the javascript debugging. See what happens then

Configure AJAX properly

http://www.asp.net/AJAX/Documentation/Live/ConfiguringASPNETAJAX.aspx


Hiasppick,

Please refer to these entries:

http://blogs.msdn.com/delay/archive/2007/02/05/safely-avoiding-the-access-denied-dialog-how-to-work-around-the-access-denied-cross-domain-iframe-issue-in-the-ajax-control-toolkit.aspx

http://weblogs.asp.net/bleroy/archive/2007/01/31/how-to-work-around-the-quot-access-denied-quot-cross-domain-frame-issue-in-asp-net-ajax-1-0.aspx

Hope this helps.

Access custom server classes from Javascript

I am in the process of migrating my VS2005/Atlas app to VS2008/ASP.Net AJAX.

In the old app I could instantiate custom c# classes on the server from within javascript.

An example would be var myObj = new MM.Test();

In the new app this no longer works and throws the 'object expected' exception.

Any ideas what I need to do in order to get this to work?

You have to mark your Webservice/WebMethod with the GenerateScriptType attribute which will include the server side types that you need to create in the client. for the above you have to add the following:

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
[GenerateScriptType(typeof(MM.Test))]
public class MyService
{
.........................
.........................
}


Thanks for that.

Should intellisense sense then work on the members of this class?

Also, my usage is more complex than that. I have a class named Contract that has a generic collection as one of its members. You don't seem to be able to use GenerateScriptType with generic collections so how do I access the collection and its members (specifically the add method.which worked fine using VS2005/Atlas)?

public class Contract
{
public Contract();
public PeriodCollection Periods { get; set; }

}

public class PeriodCollection : Collection<Period>
{
public PeriodCollection();
public string Year { get; set; }
}


I think the intellisens should work if you are working in VS2008.

You do not have to worry about the Collection, it will be convertet to JS Array no matter it is Generic or Regular Collection.

In that case you should add more than one GenerateScriptType in your Web Service or WebMethod.

[GenerateScriptType(typeof(class1))]
[GenerateScriptType(typeof(class2))]
[GenerateScriptType(typeof(class3))]
public class MyService{
}

Hope this will help .and mark it as answer if it solves your issue.

Access ClearMaskOnLostfocus value in Javascript

Hi, everybody

I want to access ClearMaskOnLostfocus value in javascript, is it possile??

Thanks in advance...

Type.registerNamespace('AjaxControlToolkit');

AjaxControlToolkit.MaskedEditBehavior =function(element)

{

// **************************************************

// Properties

// **************************************************

this._ClearMaskOnLostfocus =true;

Yes, you can set this property via javascript.

1. Get a reference to the component via $find method

2. Call set_ClearMaskOnLostFocus method on this component

For instance, say you have a MaskedEditExtender as following:

<ajaxToolkit:MaskedEditExtender ID="meeGrossSalesNCRPerStop"BehaviorID="mee" .... />


function change()
{
var mee = $find("mee");
mee. set_ClearMaskOnLostFocus(false);
}

Hope this helps.

Access class from inline frame

I have a composite control with associated javascript. The javascript uses registerClass to register a class. What I'd like to be able to do is access a method in this class from outwith my control, from another frame to be specific. Normally I'd simply do parent.class.method but when I try that I get a "not a function" error. When I try alerting the class I get the javascript code for it and not the instance.

So how do I get the instance of the class registered with registerClass from within another frame, if it is at all possible.

Thanks.

Hi

Would you please provide us with your code,so we can reproduce this issue quicklier?

Thanks


Thanks for the reply.

This is the javascript code for the control, I have snipped some of the functions to cut the length.

Type.registerNamespace('number45');

number45.editor = function(element) {

number45.editor.initializeBase(this, [element]);

this.type = 'editor';
this.editor_obj_id = '';
this.toolbar_id = '';
this.colors = '';

this.popups = new Array();
this.buttons = new Array();
this.popupshowing = '';
};

number45.editor.prototype = {

initialize: function()
{
number45.editor.callBaseMethod(this, 'initialize');

this.editor_obj = document.getElementById(this.editor_obj_id);

var documentClick = Function.createDelegate(this, this.close);
$addHandler(document, 'click', documentClick);
},

dispose : function() {
$clearHandlers(this.get_element());

number45.editor.callBaseMethod(this, 'dispose');
},

get_editor_obj_id: function()
{
return this.editor_obj_id;
},

set_editor_obj_id: function(value)
{
this.editor_obj_id = value;
},

insertText : function(newtext) {
this.checkFocus();
if (document.selection)
document.selection.createRange().text = newtext;
else {
if (typeof(this.editor_obj.selectionStart) != 'undefined') {
this.editor_obj.value = this.editor_obj.value.substr(0, this.editor_obj.selectionStart) + newtext + this.editor_obj.value.substr(this.editor_obj.selectionEnd, this.editor_obj.value.length);
} else {
this.editor_obj.value += newtext;
}
}
},

insertAttachment : function(attachment) {
var start_tag = '[image]';
var end_tag = '[/image]'

this.insertText( start_tag + attachment + end_tag );
},

}

number45.editor.registerClass('number45.editor', Sys.UI.Control);

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();

function stop_bubble(obj) {
if (!obj) {
window.event.cancelBubble=true;
return window.event;
} else {
obj.stopPropagation();
return obj;
}
};

It is the functioninsertAttachment I want to call from the inline frame. I have tried usingparent.number45.editor.insertAttachment('x'), this is what causes the 'not a function' error. When I try alertingparent.number45.editor I get the body of thefunction(element) shown.

Access amazon Webservice by javascript in pure html form

I am developing pure html form,

in that i want to show amazon webserice where i dont have any server side, so alternatively

i used some javascript but it is not succesfull,

any one have idea in accessing amazon webservice in javascript ,

You might want to check the Amazon forums. I'm sure they might be able to assist you more with questions regarding their WebService. You could also try checking Google Groups and Yahoo! Developer Network.

http://developer.amazonwebservices.com/connect/forumindex.jspa?categoryID=1



It is not possible to call Amazon WebService from JS Directly due to the Cross Domain. To resolve it create a web service (Which acts as a proxy) which inturn call the amazon webservice. and from JS call your Webservice.


Thanks for this great and amazing simple indian Ajax solution, Pragash.T.


Thanks To every Body ,

i found the solution using iframe tag we can do this , sample code for amazon dvd ads.

<iframesrc="http://rcm-uk.amazon.co.uk/e/cm?t=amazo04-21&o=2&p=36&l=bn1&mode=dvd-uk&browse=501778&fc1=000000<1=&lc1=3366FF&bg1=FFFFFF&f=ifr"

marginwidth="0"marginheight="0"width="600"height="520"border="0"frameborder="0"

style="border: none;"scrolling="no"></iframe>

The url to achieve this ishttps://affiliate-program.amazon.co.uk/gp/associates/login/login.html/202-5683437-3533413

Regards

Pragash.T

Insoft,Chennai

Saturday, March 24, 2012

Access a server-side control from JavaScript in beta 2

Sorry if this has been asked already, I tried search but no luck.

Okay, I have a server-side control defined as


<asp:Textbox id="textboxonserver" runat="server" />

What I want to achieve is to set the value of this control from client side javascript. document.getElementById("textboxonserver") won't work since the real id on page is something like ctrl$palceholder$textboxonserver. Tried $find, still nothing.

I know I can get the value by doing something like


My.prototype = {

_textboxid: null

...


Then set the textboxid = this.textboxonserver.ClientID inside the pageload() loop. But isn't this a bit overkill just for that purpose.

Thanks

nvm...i found the answer myself:

inside my javascript I can actually do this:

var txtboxid = "<%= textboxonserver.ClientID %>";

then use document.getElementById(txtboxid) to get the object in DOM tree. Just not sure if this is the elegant way to do this although it works..


ugh...sorrySad problem still stands..

abortPostBack(); is not working..

Hi, I

I have written a javascript file as

Sys.Application.add_load(ApplicationLoadHandler)

function ApplicationLoadHandler(sender, args)

{

Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(CheckStatus);

}

function CheckStatus(sender, args)

{

var prm = Sys.WebForms.PageRequestManager.getInstance();if (prm.get_isInAsyncPostBack() & args.get_postBackElement().id =='CancelRefresh')

{

alert('cancelling');

prm.abortPostBack();

alert('cancelled');

}

}

if(typeof(Sys) !=="undefined") Sys.Application.notifyScriptLoaded();

----------------

I have written this to cancel my dropdown list postback But request is not cancelling.

My .aspx code.. is

<formid="form1"runat="server">

<asp:ScriptManagerID="ScriptManager1"runat="server">

<Scripts>

<asp:ScriptReferencePath="Cancel.js"/>

</Scripts>

</asp:ScriptManager>

<div>

<asp:UpdatePanelID="UpdatePanel1"runat="server">

<ContentTemplate>

<asp:DropDownListrunat="server"ID="ddl_testing"OnSelectedIndexChanged="ddl_testing_SelectedIndexChanged"AutoPostBack="True">

<asp:ListItemText="Manoj"></asp:ListItem>

<asp:ListItemText="Atul"></asp:ListItem>

<asp:ListItemText="Punit"></asp:ListItem>

</asp:DropDownList>

<asp:LabelID="Label1"runat="server"Text="Label"></asp:Label><br/>

<br/>

<asp:ButtonID="CancelRefresh"runat="server"Text="Cancel"/>

</ContentTemplate>

</asp:UpdatePanel>

</div>

</form>

While my .cs code is as follow..

protectedvoid Page_Load(object sender,EventArgs e)

{

Label1.Text = ddl_testing.SelectedItem.Text;

}

protectedvoid ddl_testing_SelectedIndexChanged(object sender,EventArgs e)

{

System.Threading.Thread.Sleep(2000);

Label1.Text = ddl_testing.SelectedItem.Text.ToString();

}

}

But my ajax request is not cancelling on clikcking cancel button ..Can anybody tell me why..

Thanks in advance..

Since the Cancel button resides in the UpdatePanel it appends the NamingContainer in the ID.
Try indexof instead of exatct match:

args.get_postBackElement().id.indexOf ('CancelRefresh') > -1