Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

.NET Forum


You are currently viewing our .NET Forum as a guest. Please register to participate.
Login



Reply
Raise custom event with
Old 07-01-2007, 11:16 AM Raise custom event with
Junior Talker

Posts: 4
Name: Karen Tse
Trades: 0
I have a full custom server control with javascript embedded.

In short it will list out images and when an image is selected, it will be displayed as the first image at the top. And this top image can be collapsed and expanded when clicked.

I am very confused how to raise a custom event when an image is clicked. And how to return two string arguments to the client via the event arguments of the event (index number of the item selected, and a short description of item).

A snippet from RenderContents. Will post the rest of the code upon request.

Code:
   Protected Overrides Sub RenderContents(ByVal output As HtmlTextWriter)
        output.WriteLine("<script language=javascript>                          ")
        output.WriteLine("function CollapseExpand() {                              ")
        output.WriteLine("var div = document.getElementById(div01);    ")
        output.WriteLine("if (div.style.display != 'none') {                         ")
        output.WriteLine("div.style.display = 'none';                                 ")
        output.WriteLine("} else {                                                              ")
        output.WriteLine("div.style.display = '';                                         ") ' or = block
        output.WriteLine(" }}                                                                      ")

        'output.WriteLine("var top;                                                              ")
        'output.WriteLine("function SetDefault(i) {                                      ")
        'output.WriteLine("var img = document.getElementById(i);            ")
        'output.WriteLine("if (img.src != top.src') {                                      ")
        'output.WriteLine("img.src = 'none';                                                 ")
        'output.WriteLine("} else {                                                                ")
        'output.WriteLine("div.style.display = '';                                          ") ' or = block
        'output.WriteLine(" }                                                                         ")

        output.WriteLine("}</script>                                                       ")

        'image at the top
        output.AddAttribute(HtmlTextWriterAttribute.Src, TopImageUrl)
        output.AddAttribute(HtmlTextWriterAttribute.Onclick, "CollapseExpand()")
        output.RenderBeginTag(HtmlTextWriterTag.Img)
        output.RenderEndTag() 'end img

        output.AddStyleAttribute(HtmlTextWriterStyle.Top, "100")
        output.AddStyleAttribute(HtmlTextWriterStyle.Left, "100")
        output.AddStyleAttribute(HtmlTextWriterStyle.Width, "100")
        output.AddStyleAttribute(HtmlTextWriterStyle.Height, "500")
        output.AddStyleAttribute(HtmlTextWriterStyle.Padding, "5")
        output.AddStyleAttribute(HtmlTextWriterStyle.Overflow, "hidden") ' for scrollbar use "auto"
        output.AddStyleAttribute(HtmlTextWriterStyle.Display, "none")
        output.AddAttribute("id", "div01")
        output.RenderBeginTag(HtmlTextWriterTag.Div)

        'add the remaining images
        Dim item As Object
        Dim i As Byte
        For Each item In imageurl
            output.WriteLine("<br>")
            output.AddAttribute(HtmlTextWriterAttribute.Src, imageurl.Item(i))
            'output.AddAttribute("Onmouseover", "Inform()")
            'output.AddAttribute("Onmouseout", "UnInform()")
            'output.AddAttribute(HtmlTextWriterAttribute.Onclick, "SetDefault(this)")
            'output.AddAttribute(HtmlTextWriterAttribute.Id, i.ToString)
            output.RenderBeginTag(HtmlTextWriterTag.Img)
            output.RenderEndTag() 'end img

            i += 1

            'Dim s1 As New SelectEventArgs
            's1.ItemNoArg = i
            's1.DescArg = imagedescription.Item(i)
            'Me.TopImageUrl = imageurl.Item(i)
            'OnSelectedChanged(s1)

        Next

        output.RenderEndTag() 'end div
    End Sub
Thanks for viewing. And would appreciate any help.

Last edited by kt_sc; 07-01-2007 at 11:17 AM.. Reason: forgot to add in a few lines.
kt_sc is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Raise custom event with
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19248 seconds with 12 queries