예제 #1
0
 /// <include file='doc\WmlFormAdapter.uex' path='docs/doc[@for="WmlFormAdapter.RenderExtraCardElements"]/*' />
 protected internal virtual void RenderExtraCardElements(WmlMobileTextWriter writer)
 {
     Form form = this.Control as Form;
     if((form != null) && (form.Script != null))
     {
         foreach(Control childControl in form.Script.Controls)
         {
             LiteralControl lc = childControl as LiteralControl;
             if(lc != null)
             {
                 writer.Write(lc.Text);
             }
             else
             {
                 DataBoundLiteralControl dlc = childControl as DataBoundLiteralControl;
                 if(dlc != null)
                 {
                     writer.Write(dlc.Text);
                 }
             }
         }
     }
  }
        /// <include file='doc\WmlPageAdapter.uex' path='docs/doc[@for="WmlPageAdapter.Render"]/*' />
        public override void Render(WmlMobileTextWriter writer)
        {
            if (RequiresUTF8ContentEncoding())
            {
                Page.Response.ContentEncoding = UTF8Encoding;
            }

            writer.BeginResponse();
            writer.BeginFile(Page.Request.Url.ToString(), _contentType, Page.Response.Charset);

            RenderXmlHeader(writer);

            writer.WriteFullBeginTag("wml");

            if (Device.SupportsCacheControlMetaTag)
            {
                writer.Write(_cacheExpiry);
            }
            else
            {
                Page.Response.AppendHeader("Cache-Control", "max-age=0");
            }

            if (Device.CanCombineFormsInDeck)
            {
                _renderableForms = Page.ActiveForm.GetLinkedForms(OptimumPageWeight);
                Debug.Assert(_renderableForms != null, "_renderableForms is null");
            }
            else
            {
                _renderableForms = new ArrayList();
                _renderableForms.Add(Page.ActiveForm);
            }

            foreach (Form form in _renderableForms)
            {
                RenderForm(writer, form);
            }

            writer.RenderExtraCards();

            writer.WriteEndTag("wml");

            writer.EndFile();
            writer.EndResponse();
        }
        /// <include file='doc\WmlObjectListAdapter.uex' path='docs/doc[@for="WmlObjectListAdapter.RenderItemsList"]/*' />
        protected virtual void RenderItemsList(WmlMobileTextWriter writer)
        {
            bool rendersAcceptsInline = Device.RendersWmlDoAcceptsInline;
            bool rendersSelectsAsMenuCards = Device.RendersWmlSelectsAsMenuCards;
            bool rendersBreaksAfterAnchor = Device.RendersBreaksAfterWmlAnchor;
            int pageStart = Control.FirstVisibleItemIndex;
            int pageSize = Control.VisibleItemCount;
            ObjectListItemCollection items = Control.Items;

            if (pageSize == 0 || items.Count == 0)
            {
                return;
            }

            bool hasDefaultCommand = HasDefaultCommand();
            bool onlyHasDefaultCommand = OnlyHasDefaultCommand();
            bool requiresSecondScreen = HasItemDetails() || (!onlyHasDefaultCommand && HasCommands());
            bool itemRequiresHyperlink = requiresSecondScreen || hasDefaultCommand;

            writer.EnterLayout(Style);

            int[] tableFieldIndices = null;
            if (ShouldRenderAsTable() && (tableFieldIndices = Control.TableFieldIndices).Length != 0)
            {
                writer.BeginCustomMarkup();
                int fieldCount = tableFieldIndices.Length;
                writer.Write("<table columns=\"");
                writer.Write(fieldCount.ToString(CultureInfo.InvariantCulture));
                writer.WriteLine("\">");

                if (ShouldRenderTableHeaders())
                {
                    writer.Write("<tr>");
                    foreach (int fieldIndex in tableFieldIndices)
                    {
                        writer.Write("<td>");
                        writer.RenderText(Control.AllFields[fieldIndex].Title);
                        writer.Write("</td>");
                    }
                    writer.WriteLine("</tr>");
                }

                for (int i = 0; i < pageSize; i++)
                {
                    ObjectListItem item = items[pageStart + i];
                    writer.Write("<tr>");
                    for (int field = 0; field < fieldCount; field++)
                    {
                        writer.Write("<td>");
                        if (field == 0 && itemRequiresHyperlink)
                        {
                            RenderPostBackEvent(writer, 
                                requiresSecondScreen ?
                                    String.Format(CultureInfo.InvariantCulture, _showMoreFormatAnchor, item.Index) :
                                    item.Index.ToString(CultureInfo.InvariantCulture),
                                GetDefaultLabel(GoLabel),
                                false,
                                item[tableFieldIndices[0]],
                                false,
                                WmlPostFieldType.Raw);
                        }
                        else
                        {
                            writer.RenderText(item[tableFieldIndices[field]]);
                        }
                        writer.Write("</td>");
                    }
                    writer.WriteLine("</tr>");
                }
                writer.WriteLine("</table>");
                writer.EndCustomMarkup();
            }
            else
            {
                int labelFieldIndex = Control.LabelFieldIndex;
                ObjectListField labelField = Control.AllFields[labelFieldIndex];

                writer.EnterFormat(Style);
                for (int i = 0; i < pageSize; i++)
                {
                    ObjectListItem item = items[pageStart + i];
                    if (itemRequiresHyperlink)
                    {
                        RenderPostBackEvent(writer, 
                            requiresSecondScreen ?
                                String.Format(CultureInfo.InvariantCulture, _showMoreFormatAnchor, item.Index) :
                                item.Index.ToString(CultureInfo.InvariantCulture),
                            GetDefaultLabel(GoLabel),
                            false,
                            item[labelFieldIndex],
                            true,
                            WmlPostFieldType.Raw);
                    }
                    else
                    {
                        writer.RenderText(item[labelFieldIndex], true);
                    }
                }
                writer.ExitFormat(Style);
            }

            writer.ExitLayout(Style);
        }