Ver Mensaje Individual
  #3 (permalink)  
Antiguo 24/05/2010, 08:00
Avatar de Bravenap
Bravenap
 
Fecha de Ingreso: noviembre-2002
Ubicación: Los Arroyos, El Escorial, Madrid
Mensajes: 2.084
Antigüedad: 21 años, 5 meses
Puntos: 4
Respuesta: Insertar etiqueta de control personalizado en AJAX HTML Editor

Bueno, más o menos resuelto sólo para dos controles personalizados (descarga de documentos y nota lateral). Os lo dejo por si sirve de ayuda a alguien (y también para mejorarlo y sugerir, claro):
Código vb:
Ver original
  1. Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
  2.             writer.Write(String.Format("<h1>{0}</h1>", Titulo))
  3.             writer.Write("<!-- Iniciando proceso de contenido -->")
  4.             writer.Write(procesarContenidos(Contenido))
  5.             writer.Write("<!-- Contenido procesado -->")
  6.             writer.Write(String.Format("<div class=""fechasSeccion"">Publicado: {0:dd/MM/yyyy}", FechaPublicacion))
  7.             If FechaActualizacion <> FechaPublicacion Then
  8.                 writer.Write(String.Format(" Última actualización: {0:dd/MM/yyyy}</div>", FechaActualizacion))
  9.             End If
  10.             writer.Write("</div>")
  11.         End Sub
  12.  
  13.         Private Function procesarContenidos(ByVal texto As String) As String
  14.             Dim er As New System.Text.RegularExpressions.Regex("")
  15.             Dim strPatt As String = String.Empty
  16.             Dim match As System.Text.RegularExpressions.Match
  17.             Dim sb As StringBuilder
  18.             Dim tw As System.IO.StringWriter
  19.             Dim hw As HtmlTextWriter
  20.  
  21.             'Procesa primero todos los controles de descarga de documentos
  22.            '(HyperLink personalizado) ya que no pueden tener controles hijo
  23.            strPatt = "\[cpersDescargaDocumento NavigateUrl=""(?<NavigateUrl>[^\s]*)"" Target=""([^\s]*)"" Text=""(?<Text>[^""]*)"" /\]"
  24.             Do While er.Match(texto, strPatt).Success
  25.                 sb = New StringBuilder
  26.                 tw = New System.IO.StringWriter(sb)
  27.                 hw = New HtmlTextWriter(tw)
  28.                 match = er.Match(texto, strPatt)
  29.                 Dim dd As New ControlesPersonalizados.DescargaDocumento
  30.                 dd.NavigateUrl = match.Groups("NavigateUrl").Value
  31.                 dd.Target = match.Groups("Target").Value
  32.                 dd.Text = match.Groups("Text").Value
  33.                 dd.RenderControl(hw)
  34.                 texto = String.Format("{0}{1}{2}", _
  35.                     texto.Substring(0, match.Index), _
  36.                     sb.ToString, _
  37.                     texto.Substring(match.Index + match.Length))
  38.             Loop
  39.  
  40.             'Procesa los cuadros de notas laterales (Panel personalizado)
  41.            strPatt = "\[cpersCuadroNotas Titulo=""(?<Titulo>[^\""]*)""\](?<Contenido>.*)\[/cpersCuadroNotas\]"
  42.             Do While er.Match(texto, strPatt).Success
  43.                 sb = New StringBuilder
  44.                 tw = New System.IO.StringWriter(sb)
  45.                 hw = New HtmlTextWriter(tw)
  46.                 match = er.Match(texto, strPatt)
  47.                 Dim cn As New ControlesPersonalizados.CuadroNotas
  48.                 cn.Titulo = match.Groups("Titulo").Value
  49.                 cn.ContenidoAlternativo = match.Groups("Contenido").Value
  50.                 cn.RenderControl(hw)
  51.                 texto = String.Format("{0}{1}{2}", _
  52.                     texto.Substring(0, match.Index), _
  53.                     sb.ToString, _
  54.                     texto.Substring(match.Index + match.Length))
  55.             Loop
  56.  
  57.             Return texto
  58.         End Function
Un saludo.
__________________
¡¡NO A LA GUERRA!!
Si ponemos a nuestros mensajes títulos adecuados, la gente se animará más a abrirlos y resultarán más útiles en las busquedas. ¡No a los ayuuudaaa, urgenteee y similares!