473,795 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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='On MouseOver(" + i + ")'
href='javascrip t: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 1947
Hi Jeronimo,

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

Page.RegisterSt artupScript Method
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwebu ipageclassregis terstartupscrip ttopic.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="On MouseOver(0)" href="javascrip t:void(0)" shape=circle
coords='10,20,5 '>

<area onmouseover="On MouseOver(1)" href="javascrip t: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.RegisterSc ript methods as Jacob suggests.
You can assign the map to the image on the server by
accessing the image's attributes collection. eg
Image1.Attribut es.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="On MouseOver(0)" href="javascrip t:void (0)" shape=circlecoords='10,20, 5'>

<area onmouseover="On MouseOver(1)" href="javascrip t: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******@bertr an.com> wrote in message
news:Xn******** *************** *********@207.4 6.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="On MouseOver(0)" href="javascrip t:void(0)" shape=circle
coords='10,20,5 '>

<area onmouseover="On MouseOver(1)" href="javascrip t: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
4525
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 sleuthing, I was able to find what serves as a document.getElementById emulator at http://www.xs4all.nl/~ppk/js/dhtmloptions.html#versionb. (Below is the code; this clever algorithm is painstakingly explained at the site above.)
13
9651
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 assigned to a variable and output using document.write. (Note, there is no submit button or other form elements. Basically
136
9460
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 code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
1
1521
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 Studio .NET to pull that into a solution, or would I have to cut and paste and recreate from scratch? TIA -- Steve Wasser http://xdissent.com
6
2770
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
1828
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. I am just starting my journey into the .NET world, moving from a pure ASP one.
0
1444
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 content, I want to create a new instance of an XML document and write the data to the XML doc using the Word ML schema. The key item is that I want to be able to add content line-by-line or section-by-section, to the word document using the XML...
34
4077
by: subramanian100in | last post by:
Is there any difference between porting and migrating. Kindly explain
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10437
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10164
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3723
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.