migrating Document.Write to Code Behind

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeronimo Bertran

    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
  • Jacob Yang [MSFT]

    #2
    RE: migrating Document.Write to Code Behind

    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

    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.

    Comment

    • Jeronimo Bertran

      #3
      RE: migrating Document.Write to Code Behind

      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

      Comment

      • alex bowers

        #4
        RE: migrating Document.Write to Code Behind

        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[color=blue]
        >-----Original Message-----
        >Hi Jacob
        >
        >After re-reading my question I realized how poorly I had[/color]
        described it.[color=blue]
        >Here's another shot:
        >
        >I need to create a map object dynamically. The number[/color]
        of areas in the map[color=blue]
        >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[/color]
        (0)" shape=circle[color=blue]
        >coords='10,20, 5'>
        >
        ><area onmouseover="On MouseOver(1)" href="javascrip t:void[/color]
        (0)" shape=circle[color=blue]
        >coords='40,33, 5'>
        ></map>
        >
        >
        >My question is, if I create a WebControl that includes[/color]
        an image object and[color=blue]
        >create the image programatically by using the HtmlImage[/color]
        class, is their a[color=blue]
        >way to create the map object and assign it to the image?
        >
        >Thanks!!
        >Jeronimo
        >.
        >[/color]

        Comment

        • Kevin Spencer

          #5
          Re: migrating Document.Write to Code Behind

          Sure. All you have to do is dynamically build your tag.

          --
          HTH,

          Kevin Spencer
          Microsoft MVP
          ..Net Developer
          All hotels in Benidorm. The best selection of Benidorm hotels with reviews and maps. Book in advance and save.

          Big Things are made up of
          Lots of Little Things.

          "Jeronimo Bertran" <jeronimo@bertr an.com> wrote in message
          news:Xns9432DC7 D366EDjeronimob ertrancom@207.4 6.248.16...[color=blue]
          > 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[/color]


          Comment

          Working...