コード例 #1
0
ファイル: TextBox.cs プロジェクト: thetownfool/anthemnxt
 /// <summary>
 /// Adds the <strong>onchange</strong> attribute to invoke a callback from the client, then renders
 /// the attributes of the control to the output stream.
 /// </summary>
 protected override void AddAttributesToRender(HtmlTextWriter writer)
 {
     if (AutoCallBack)
     {
         EventHandlerManager.AddScriptAttribute(
             this,
             "onchange",
             EventHandlerManager.GetCallbackEventReference(
                 this,
                 this.CausesValidation,
                 this.ValidationGroup
                 )
             );
     }
     base.AddAttributesToRender(writer);
 }
コード例 #2
0
ファイル: BulletedList.cs プロジェクト: thetownfool/anthemnxt
 /// <summary>
 /// Adds the <strong>onclick</strong> attribute to invoke a callback from the client, then renders
 /// the attributes of the control to the output stream.
 /// </summary>
 protected override void AddAttributesToRender(HtmlTextWriter writer)
 {
     base.AddAttributesToRender(writer);
     if (this.DisplayMode == ASP.BulletedListDisplayMode.LinkButton)
     {
         for (int index = 0; index < this.Items.Count; index++)
         {
             ASP.ListItem item = this.Items[index];
             EventHandlerManager.AddScriptAttribute(
                 this,
                 item,
                 "onclick",
                 EventHandlerManager.GetCallbackEventReference(
                     this,
                     index.ToString(),
                     this.CausesValidation,
                     this.ValidationGroup
                     ) + "return false;"
                 );
         }
     }
 }
コード例 #3
0
        /// <summary>
        /// Adds the <strong>onclick</strong> attribute to each item to invoke a callback from the client,
        /// then renders the item.
        /// </summary>
        protected override void RenderItem(ASP.ListItemType itemType, int repeatIndex, ASP.RepeatInfo repeatInfo, HtmlTextWriter writer)
        {
            if (AutoCallBack)
            {
                ASP.ListItem item = this.Items[repeatIndex];
                if (item.Selected)
                {
                    item.Attributes.Remove("onclick");
                }
                else
                {
                    item.Attributes["onclick"] = EventHandlerManager.GetCallbackEventReference(
                        this,
                        repeatIndex.ToString(),
                        this.CausesValidation,
                        this.ValidationGroup
                        );
                }
            }

            base.RenderItem(itemType, repeatIndex, repeatInfo, writer);
        }
コード例 #4
0
        /// <summary>
        /// Overrides the pretty useless ASP.NET 2.0 rendering of an ImageMap and replaces with a Anthem.NET capable (replaces the POST type maps) control that
        /// is also fully XHTML compatible.
        /// </summary>
        /// <param name="writer"></param>
        protected override void Render(HtmlTextWriter writer)
        {
            // Anthem preamble
            if (!DesignMode)
            {
                AnthemNxt.Core.Manager.WriteBeginControlMarker(writer, "span", this);
            }

            if (Visible)
            {
                // Manually render the underlying image due to not being able to skip the base.Render imagemap implementation
                RenderUnderlyingImage(writer);

                // Only output if there is at least one hotspot
                if (Enabled && !base.IsEnabled)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
                }
                if (HotSpots.Count > 0)
                {
                    // Imagemap preamble, creating a new "sub" ID for the map which is referred to by the image
                    string id = "ImageMap" + this.ClientID;
                    writer.AddAttribute(HtmlTextWriterAttribute.Id, id);
                    writer.AddAttribute(HtmlTextWriterAttribute.Name, id);
                    writer.RenderBeginTag(HtmlTextWriterTag.Map);

                    int i = 0;
                    foreach (HotSpot spot in HotSpots)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Shape, GetHotSpotMarkupName(spot), false);
                        writer.AddAttribute(HtmlTextWriterAttribute.Coords, spot.GetCoordinates());

                        // What kind of hotspot is this? POST of course is now routed through Anthem.
                        switch (spot.HotSpotMode)
                        {
                        case HotSpotMode.NotSet: throw new NotSupportedException("HotSpotMode.NotSet not supported");

                        case HotSpotMode.PostBack:
                            if (Page != null)
                            {
                                Page.VerifyRenderingInServerForm(this);
                            }

                            // Registers the click to fire back via AJAX
                            writer.AddAttribute(HtmlTextWriterAttribute.Onclick,
                                                EventHandlerManager.GetCallbackEventReference(
                                                    this,                                           // Reference to this ICallbackControl
                                                    spot.PostBackValue,                             // The event argument
                                                    false,                                          // Causes validation
                                                    string.Empty,                                   // Validation group
                                                    string.Empty                                    // Image during callback
                                                    ));

                            // Added otherwise most browsers won't render the map with the correct mouse cursor
                            writer.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:void(0);");
                            break;

                        case HotSpotMode.Navigate:
                            writer.AddAttribute(HtmlTextWriterAttribute.Href, ResolveClientUrl(spot.NavigateUrl));
                            if (spot.Target.Length > 0)
                            {
                                writer.AddAttribute(HtmlTextWriterAttribute.Target, spot.Target);
                            }
                            break;

                        case HotSpotMode.Inactive:
                            writer.AddAttribute("nohref", "true");
                            break;
                        }

                        // Add general hotspot attributes
                        writer.AddAttribute(HtmlTextWriterAttribute.Title, spot.AlternateText);
                        writer.AddAttribute(HtmlTextWriterAttribute.Alt, spot.AlternateText);
                        if (AccessKey.Length > 0)
                        {
                            writer.AddAttribute(HtmlTextWriterAttribute.Accesskey, AccessKey);
                        }
                        if (TabIndex != 0)
                        {
                            writer.AddAttribute(HtmlTextWriterAttribute.Tabindex, spot.TabIndex.ToString());
                        }

                        // Hotspot postamble
                        writer.RenderBeginTag(HtmlTextWriterTag.Area);
                        writer.RenderEndTag();
                        i++;
                    }

                    // Imagemap postamble
                    writer.RenderEndTag();
                }
            }

            // Anthem postamble
            if (!DesignMode)
            {
                AnthemNxt.Core.Manager.WriteEndControlMarker(writer, "span", this);
            }
        }