473,397 Members | 2,068 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.

migrating Document.Write to Code Behind

This may be a very simple question.

I have some old java code that uses scripting to dynamically create a <MAP>
in my HTML.
<map name="Map">
<script>
var i;
for (i=0; i<arr.length; i++)
{
document.write("<area onmouseover='OnMouseOver(" + i + ")'
href='javascript:ShowDetails(" + arr[i].Id + ")' shape=circle coords='" +
arr[i].X + "," + arr[i].Y + ",5'>\r\n");
}

</script>
</map>
I am now converting this code to C# and trying to use Code Behind. How can
I achieve the same result?

Thanks

Jeronimo
Nov 17 '05 #1
4 1925
Hi Jeronimo,

As I understand, what you really need is emit client-side script blocks in
the server side. We can use the Page.RegisterStartupScript Method. Please
refer to the following URL for the detailed information and code snippet.

Page.RegisterStartupScript Method
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwebuipageclassregisterstartupscripttopi c.asp

Does it answer your question? If I have misunderstood your concern, please
feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #2
Hi Jacob

After re-reading my question I realized how poorly I had described it.
Here's another shot:

I need to create a map object dynamically. The number of areas in the map
is variable and needs to be created dynamically.

example:

<img src="Img/map01.gif" border="0" usemap="#Map">
<map name="Map">
<area onmouseover="OnMouseOver(0)" href="javascript:void(0)" shape=circle
coords='10,20,5'>

<area onmouseover="OnMouseOver(1)" href="javascript:void(0)" shape=circle
coords='40,33,5'>
</map>
My question is, if I create a WebControl that includes an image object and
create the image programatically by using the HtmlImage class, is their a
way to create the map object and assign it to the image?

Thanks!!
Jeronimo
Nov 17 '05 #3
Jeronimo,
Creating the map dynamically can be done on the server
either by designing a custom control that renders html as
you wish, or by adding the script using one of the
Page.RegisterScript methods as Jacob suggests.
You can assign the map to the image on the server by
accessing the image's attributes collection. eg
Image1.Attributes.Add("usemap","#Map").

Hope this helps you.

alex
-----Original Message-----
Hi Jacob

After re-reading my question I realized how poorly I had described it.Here's another shot:

I need to create a map object dynamically. The number of areas in the mapis variable and needs to be created dynamically.

example:

<img src="Img/map01.gif" border="0" usemap="#Map">
<map name="Map">
<area onmouseover="OnMouseOver(0)" href="javascript:void (0)" shape=circlecoords='10,20,5'>

<area onmouseover="OnMouseOver(1)" href="javascript:void (0)" shape=circlecoords='40,33,5'>
</map>
My question is, if I create a WebControl that includes an image object andcreate the image programatically by using the HtmlImage class, is their away to create the map object and assign it to the image?

Thanks!!
Jeronimo
.

Nov 17 '05 #4
Sure. All you have to do is dynamically build your tag.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Jeronimo Bertran" <je******@bertran.com> wrote in message
news:Xn********************************@207.46.248 .16...
Hi Jacob

After re-reading my question I realized how poorly I had described it.
Here's another shot:

I need to create a map object dynamically. The number of areas in the map
is variable and needs to be created dynamically.

example:

<img src="Img/map01.gif" border="0" usemap="#Map">
<map name="Map">
<area onmouseover="OnMouseOver(0)" href="javascript:void(0)" shape=circle
coords='10,20,5'>

<area onmouseover="OnMouseOver(1)" href="javascript:void(0)" shape=circle
coords='40,33,5'>
</map>
My question is, if I create a WebControl that includes an image object and
create the image programatically by using the HtmlImage class, is their a
way to create the map object and assign it to the image?

Thanks!!
Jeronimo

Nov 17 '05 #5

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

Similar topics

6
by: 2obvious | last post by:
This is a pipe dream, I realize, but I'm trying to emulate the functionality of the W3C DOM-supported document.getElementsByTagName method under the very nightmarish Netscape 4. Through some...
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
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...
1
by: Steve Wasser | last post by:
While not specific to C# (although I am coding in C#). I have a website I've developed using Dreamweaver, and am rapidly getting sick of it. Is there an import or migration function for Visual...
6
by: Shai Levi | last post by:
Hi, I'm trying to migrate native c++ class to managed c++ class. The native class header definition looks as: class NativeClass { public: typedef void (CbFunc1)(int n,void* p);
3
by: BobRoyAce | last post by:
I would really appreciate recommendations for sources of materials on migrating ASP applications to ASP.NET (books, URL's, etc.). Also, is there a magazine that is particularly good for .NET stuff....
0
by: CognitiveFlux | last post by:
Hi All, I'm pretty new to .Net, not to mention XML, so I truly appreciate any advice! I have user data that I want to selectively insert into a MS Word document in XML. Given the various...
34
by: subramanian100in | last post by:
Is there any difference between porting and migrating. Kindly explain
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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,...

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.