473,397 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Best way to Register Client Script objects?

How does everyone register and access input objects on the client side?

well... i suppose i am after some alternate ways... i use the following code to put the neccessary client javascript code so that i can then use them later...

private void RegisterClientObjects()

{

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

sBuild.Append("<script language=javascript>\n");

sBuild.Append("<!--\n");

sBuild.Append("var oSalary = document.getElementById('"+ this.Salary.ClientID.ToString() +"');\n");

sBuild.Append("var oWorkType = document.getElementById('"+ this.WorkType.ClientID.ToString() +"');\n");

sBuild.Append("//-->\n");

sBuild.Append("</script>\n");

this.Page.RegisterStartupScript("JR_LoadWorkTypeLa bel",sBuild.ToString());

}

Nov 18 '05 #1
1 1740
Hi Darren:

Instead of string builder you might consider using one large string
literal. The benefit is all the append statements do not have to
execute on each request for the page.

Maintaining javascript in a code behind file can be tedious. A few
times I have kept the script in a .js file where it can be easily
written and tested. On application startup I read the file contents
and keep the string in Cache for RegisterStartupScript.

Just a thought,

--
Scott
http://www.OdeToCode.com

On Mon, 2 Aug 2004 13:37:13 +1000, "Darren Clark"
<dc******@hotmail.com> wrote:
How does everyone register and access input objects on the client side?

well... i suppose i am after some alternate ways... i use the following code to put the neccessary client javascript code so that i can then use them later...

private void RegisterClientObjects()

{

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

sBuild.Append("<script language=javascript>\n");

sBuild.Append("<!--\n");

sBuild.Append("var oSalary = document.getElementById('"+ this.Salary.ClientID.ToString() +"');\n");

sBuild.Append("var oWorkType = document.getElementById('"+ this.WorkType.ClientID.ToString() +"');\n");

sBuild.Append("//-->\n");

sBuild.Append("</script>\n");

this.Page.RegisterStartupScript("JR_LoadWorkTypeL abel",sBuild.ToString());

}


Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Giles Brown | last post by:
I'm feeling quite dumb this morning. I'm trying to build a COM server DLL using py2exe and it ain't working. Here's what ain't working... setup_dll.py based on py2exe sample: """from...
5
by: Christoph Haas | last post by:
Dear coders... I'm working on an application that is supposed to support "plugins". The idea is to use the plugins as packages like this: Plugins/ __init__.py Plugin1.py Plugin2.py...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
5
by: Michel | last post by:
Hi there, What is the best way to serialize unknown data? I have a class that contains a list of parameter objects. The parameter has a value which can be a simple value of a complex class,...
3
by: Hardy Wang | last post by:
Hi, By calling Page.RegisterClientScriptBlock, the JavaScript will be generated right after VIEWSTATE hidden field. Is there a way I can register my script to end of page instead beginning? --...
20
by: Keith G. Murphy | last post by:
I'm trying to get a feel for what most people are doing or consider best practice. Given a mod_perl application talking to a PostgreSQL database on the same host, where different users are...
3
by: Marc Gravell | last post by:
Kind of an open question on best-practice for smart-client design. I'd really appreciate anyones views (preferably with reasoning, but I'll take what I get...). Or if anybody has any useful links...
1
by: lourivas | last post by:
Hi, I create a class with a property called MyProperty that needs to register a client script if the value is set to true. When i change the property value to true i always receive a message...
53
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.