How to Pass Information from Server-Side Code to Client-Side Code in AJAX Control Extender?

Hi All,

For some reason I can't get the following to work: I have a custom AJAX Control Extender with a few getters and setters. I also have some images I want to use with the extender saved in a resource file. How to I make the respective image URLs available to the javascript of the extender? Are there any examples available?


[Update: renamed the subject to something more appropriate.] 

1/18/2008 7:53:25 PM 17816 articles. 1 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 56
Get it on Google Play
Get it on Apple App Store

Perhaps I can clarify a bit:

I have set up a getter and setter to set the image URL from the resource file:


1    [ExtenderControlProperty]
2    public string CoverURL
3    {
4    	get { return GetPropertyValue("CoverURL", ""); }
5    	set { SetPropertyValue("CoverURL", value); }
6    }
8    protected override void  OnInit(EventArgs e)
9    {
10   	this.CoverURL = Page.ClientScript.GetWebResourceUrl(this.GetType(), "AjaxControlExtender1.Resources.spacer.png");
11   	base.OnInit(e);
12   }

 And the following in the JS file:


1    get_CoverURL : function () { return this._CoverURL; },
2    set_CoverURL : function (value) { this._CoverURL = value; },

Is there a way to populate this._CoverURL on the client-side without using extender properties? I don't want to expose this as a property to the developer using my Control Extender.


1/18/2008 10:52:49 PM


Thank you for your post!

I think you can do this in GetScriptDescriptors method:

        protected override IEnumerable<ScriptDescriptor> GetScriptDescriptors(Control targetControl)
            ScriptBehaviorDescriptor descriptor = new ScriptBehaviorDescriptor("Samples.FocusBehavior", targetControl.ClientID);
            descriptor.AddProperty("CoverURL ", Page.ClientScript.GetWebResourceUrl(this.GetType(), "AjaxControlExtender1.Resources.spacer.png"));

            return new ScriptDescriptor[] { descriptor };

For more information, see

If you have further questionss,let meknow!

Best Regards, 


Jin-Yu Yin
Microsoft Online Community Support
1/24/2008 8:03:02 AM

Similar Artilces:

client side code & server side code
what is the difference between client side coding & server side coding ? when to use client side & server side code? Client side code runs on the user's browser and includes languages such as javascript and vbscript. Server side code runs on the web server and can be written in languages such as ASP.NET, PHP, ASP, ColdFusion etc. Website Design Darlington - - Experts, Information, Ideas & Knowledge - An online resource for professional ASP.NET developersPlease remember to click "Mark as Answer...

Client side code to pass values to server side variable?
Hi there, I have ListBox_SelectedTextChanged() method that creates another list box in the runtime as follows: // Get Action Level List lbxActionLevel = new ListBox();lbxActionLevel.ID = "ddlA" + i.ToString(); lbxActionLevel.Width = 100; lbxActionLevel.Rows = 2;SqlDataReader dr = new BusinessLogicLayer().bllGetActionLevels(); lbxActionLevel.Items.Clear();while (dr.Read()) {ListItem lAction = new ListItem(); lAction.Text = dr.GetString(1).Trim();lAction.Value = Convert.ToString(dr.GetInt32(0)); lbxActionLevel.Items.Add(lAction); lbxActionLevel.SelectedIndex = 0; } I ...

How to take value from client side control from server side code?
Hi all, I would like to know that, how to access client side control in server side code? Here is an example.. I am having the textBox in client side like <input type="text" id="textBoxUsername" name="textBoxUsername"/> I need to take the value from this textBox in button click event which is server side code. private void buttonShow(object sender, System.EventArgs e) { //I need to access this textBox here. } How to do that? Thanks R. eswaran. hi you need to make it run at server. <input type="text" id="textBoxUsername"...

executing server side code and client side (javascript) code simultaneously while clicking a button
how to execute server side code and client side (javascript) code simultaneously while clicking a button in You can't. When clicking a button: the client-side executes, the page does a PostBack, then the server-side executes.NC... what if i want to update a database and then open a new windows is it possible with

client side and server side code
Making things clear:When creating a web application one must know the difference between client side code and server side code.client side code is the code that is executed on the computer of the user. server side code is the code that is executed on the ....server.why is there client side code and server side code?well... server side code exist for the reason of sharing data with multiple users. for example: accessing a database.ASP.NET is a server side technology. in you can use different languages such as VB.NET or C#.client side code is used to perform tasks on the computer of th...

Atlas client side control value available to server side C# code behind
I have an existing ASP.NET application. The page contains a datagrid (asp:datagrid). In my current C# code behind, I fetch data from SQL Server 2005 and bind to the datagrid when a button is selected (Click event). There can be many entires in the grid however, so the user typically enters text in a textbox as a filter on the returned results from SQL Server 2005. Now after studying an Atlas sample animalservice, with an HTML suggestion text box, I would like to use client-side Atlas to give the user a better indication of...

Client Side validation of Calendar control prior to server side selectionchanged event code
Hello, Any thoughts or suggestions regarding this will be greatly appreciated. I have a Calendar control with the validation constraint(can't enter appointments on Holidays or on Thursdays). To create a smoother experience, I'd like for this to be done client side. The dillema is how can I intercept or precede the <asp:calendar> controls selectionchanged event from firing and run my client javascript; passing it to the server if validation succeeds for more intensive processing and database activity. The clientside javascript will need the selected date to deter...

Client Confirmation from server side code .Provided that control is in the ajax panel
I want's an javascript confirmation message box.If user clcik yes then I want's some of my Server side property to be changed.The button is inside a ajax panel.<radA:RadAjaxPanel ID="ajaxPanel" runat="server">                                             <div class='outputColTwo floatLeft clearfix'>      ...

Calling server-side code from client-side
Hi,  I´m implementing some shortcut functionality in my web forms and wanna know where i can find something that explains, for example, how to call the handler event "onclick" of a button. I´m using this library to add shortcuts to my controls:   And I want to "link" some key combination for the event handlers of the controls. Does anybody knows?  Thanks. You could attach an AJAX event to the Javascript shortcut event handler so, for example, the shortcut function will trigger a button cl...

Client side to execute server side code
I am maintaining an ASP.NET C# application written by someone else.  I am essentially a newbie to web development especially client side stuff.  Based on reading these forums I understand that I can't directly call a server side method from the client side and I have to use post pack in some way (using a webservice is not an option here).  My confusion comes from the HTML setup being used.The page has three frames; a header, body and footer.  Each frame is filled by it's own ASPX page.  The footer contains buttons for navigating to another page and some of the b...

Execute the client side and server side code
Hi, Hi, I have two drop down lists one ddl1, ddl2. when ddl1 index is changed I have to change the label before the ddl1 and contents of ddl2. 1) to change the label before ddl2, I am using the javascript like this:ddl1.Attributes.Add("onchange", "changeLabelText(this); return false;"); Javascript function<script language="javascript"> function changeLabelText(ddl) { var indx = ddl.selectedIndex; var lbl = document.getElementById('<%= lblSelect.ClientID %>'); if(indx == 0) lbl.innerHTML = "Select A:"; if(indx == 1)lbl.i...

How to Excecute Server side code in Client Side
I have a Textbox with linkButton on right side.  if i click linkbutton i have one text box agian in poup. if we enter some text and click search button i am showing ListView with searched data in Poup. the Listview contains one Radio Button at eash row. Now my request is if i select one radiobuton and click "OK"  the poup should close and display the selected row text in TextBox in my Page where the Linkbutton Presents. i can do it on my server side on "Okbutton_Click" . i wabnt to do this in Client side only with out PostBack.   Is ther...

Is it possible to call client side function from server side code without initial client request?
Atlas is great. I'm using timer to periodically check database changes on server to populate client side controls with new data. Is it possible to do it without a lot of client requests to server which takes a huge useless network traffic? Server should call client side function on all connected clients when, for example, 'database updated' event occurs on server. Thanks. Hi~ Just for your interest, I think you could have a look at Comet, many web IM like Gmail's embeded Gtalk and are built on this architecture你好! Just FYI o_O...

what type of code is appropriate for client-side and server-side
Hi, I have a very simple and basic question.. What type of code should ideally go to the .aspx and what kind should be written in the code-behind ? For example, In an application that gets data from database and display it on the website, should I write all code in code-behind and all code related to UI such as datagrid population in JavaScript on .aspx page ?? In other words, all business logic code should go to code-behind and UI in .aspx ?? In some of the Ajax development resources, all code is written in .aspx and nothing in .cs, so I am a little confused here. Thanks, &n...

Web resources about - How to Pass Information from Server-Side Code to Client-Side Code in AJAX Control Extender? -

Information - Wikipedia, the free encyclopedia
Information (shortened as info or info. ) is that which informs, i.e. an answer to a question, as well as that from which knowledge and data ...

InformationWeek – Latest Information Technology (IT) news & IT articles - Technology news - IT magazine ...
InformationWeek provides latest Information technology (IT) news online & articles and publishes latest tech news & IT magazine for Indian IT ...

US gave San Bernardino shooter Tashfeen Malik visa 'despite missing information'
A congressman claims the US approved an entry visa even though Malik never provided the extra evidence requested by an immigration official. ...

Trudeau says improving access to information will make government better
Ensuring Canadians have access to federal information will mean more and sometimes difficult public scrutiny, but ultimately it will lead to ...

Making Access To Information Better Will Make Improve Government, Trudeau Says 54
The Liberals will conduct a "proper review" of the decades-old Access to Information Act with the aim of figuring out "what is actually going ...

Martin Peers Promoted at The Information
The Information, the tech subscription site that was founded in 2013, has named Martin Peers managing editor. Peers most recently served as ...

"Conservatives tend to be a lot more reactive to negative information and they also tend to be a lot ...
"... and they also tend to have less tolerance for ambiguity. Conservatives would prefer a negative concrete statement to a slightly positive, ...

U.S. Gave Malik Visa Despite Missing Information, Lawmaker Says
Bloomberg U.S. Gave Malik Visa Despite Missing Information, Lawmaker Says Bloomberg The U.S. approved an entry visa for Tashfeen Malik, one ...

Samsung Galaxy S7 Release Date Rumor: China Mobile Leaks Information that S7 ...
Christian Post Samsung Galaxy S7 Release Date Rumor: China Mobile Leaks Information that S7 ... Christian Post Samsung Galaxy S6 Reuters/Kim ...

IDG Contributor Network: Information security don't let the apparent complexity intimidate you
... it was. This was a humbling experience, and cause for reflection. Those of us who spend most of our time immersed in the intricacies of information ...

Resources last updated: 12/29/2015 5:16:39 PM