How to add Javascript on runtime?

Last post 03-08-2007 4:33 AM by e_screw. 5 replies.

Sort Posts:

  • How to add Javascript on runtime?

    03-07-2007, 10:32 PM
    • Loading...
    • jcjcjc
    • Joined on 11-14-2006, 4:17 AM
    • Posts 639

     

    I retrieve data from DB and add one small image of speaker on every front of row
    the result is look like

    ====================result ====================================

    [speaker image1]A: we'd better hurry. They're boarding already.
    [speaker image2]B: Ok. Let's go. But which way is Gate 20?

    ===============================================================


    the [speaker image] was added on runtime.. how to add Javascript on every image?
    because I want play sound when user click [speaker image1] user can hear "we'd better hurry. They're boarding already."
    and will hear "Ok. Let's go. But which way is Gate 20?" when user click [speaker image2]


    I understand it seems easy to reach goal by add javascript on every image icon
    the problem is image are created on run time..I've no idea how to add javescript for this request..

    thanks

     


     

  • Re: How to add Javascript on runtime?

    03-08-2007, 12:13 AM
    • Loading...
    • e_screw
    • Joined on 10-20-2004, 1:22 PM
    • Women, Guitar, Russia, Billiards, Nature, .NET
    • Posts 3,854

    I assume you are using a gridview/repeater to display all the records. When you are creating a new image on runtime, add attributes to it

    Image1.Attributes.Add("onclick", "alert('hello');");

    Thanks

    Mark post(s) as "Answer" that helped you

    Electronic Screw
    Website||Blog||Dub@i.net
  • Re: How to add Javascript on runtime?

    03-08-2007, 2:03 AM
    • Loading...
    • jcjcjc
    • Joined on 11-14-2006, 4:17 AM
    • Posts 639

    thank you.. but I'm not using gridview and repeater

    I just simply put a lable on webpage , and then add anything I retrived from DB in Label.text

    my code is :

                        lblLesson_name_eng.Text = dr["Lesson_name_eng"].ToString();
                        lblLesson_name_cht.Text = "[" + dr["Lesson_name_cht"].ToString() + "]";

                        lblContent.Text += "<img src =../../images/D3/d0-21.gif>";
                        lblContent.Text += "<br>";
                        lblContent.Text += "<img src =../../images/D3/d0-27.gif>" + dr["Lesson_text_target_name_eng"].ToString() + ":" + dr["Lesson_text_content_eng"].ToString() + "<br>";
                        lblContent.Text += "<img src =../../images/D3/d0-53.gif>" + dr["Lesson_text_target_name_cht"].ToString() + ":" + dr["Lesson_text_content_cht"].ToString() + "<br>";

     

     

    and the sound's path  is saved on colum Lesson_voice  (like this: mms://1.2.3.4/abc/def.wma) , I have to retrived path of sound from DB first..

    but now I have no idea how to add a script to let this funcation work.. please help...

     

    thank you very much

     

  • Re: How to add Javascript on runtime?

    03-08-2007, 2:35 AM
    • Loading...
    • e_screw
    • Joined on 10-20-2004, 1:22 PM
    • Women, Guitar, Russia, Billiards, Nature, .NET
    • Posts 3,854

    Do you have any code that can play the sound using javascript?

    Thanks

    Mark post(s) as "Answer" that helped you

    Electronic Screw
    Website||Blog||Dub@i.net
  • Re: How to add Javascript on runtime?

    03-08-2007, 2:44 AM
    • Loading...
    • jcjcjc
    • Joined on 11-14-2006, 4:17 AM
    • Posts 639

    honestly.. I don't

    I really don't know how to start a javacript.. I'm now trying find out the answer from textbook

     I found that

    1:

     for media player play& stop

    -- document.movieName.Play()

    -- document.movieName.Stop()

    the textbook offer a example → <A Href="javascript:mPlayer.Play()">Play</A>

    2:

    for Mouse Event

    -- onClick

    example: <IMG onClick="alert('oh!')">

    -------------------------------------------------------------

    that's what I found.. could you please help me?

    (I'm not only a new learnner in ASP.NET but also new in JavaScript.. thank you again..)

  • Re: How to add Javascript on runtime?

    03-08-2007, 4:33 AM
    Answer
    • Loading...
    • e_screw
    • Joined on 10-20-2004, 1:22 PM
    • Women, Guitar, Russia, Billiards, Nature, .NET
    • Posts 3,854

    I have found one link for you. Check this http://steveorr.net/Articles/StreamingMedia.aspx

    Let me know if you have any problems

    Thanks

    Mark post(s) as "Answer" that helped you

    Electronic Screw
    Website||Blog||Dub@i.net
Page 1 of 1 (6 items)
Microsoft Communities
Page view counter