Identificar Caracteres escondidos en una consulta SQL

CREATE FUNCTION dbo.ShowWhiteSpace (@str varchar(8000))
RETURNS varchar(8000)
AS
BEGIN
     DECLARE @ShowWhiteSpace varchar(8000);
     SET @ShowWhiteSpace = @str
     SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(32), '[?]')
     SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(13), '[CR]')
     SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(10), '[LF]')
     SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(9),  '[TAB]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(1),  '[SOH]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(2),  '[STX]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(3),  '[ETX]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(4),  '[EOT]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(5),  '[ENQ]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(6),  '[ACK]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(7),  '[BEL]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(8),  '[BS]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(11), '[VT]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(12), '[FF]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(14), '[SO]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(15), '[SI]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(16), '[DLE]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(17), '[DC1]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(18), '[DC2]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(19), '[DC3]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(20), '[DC4]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(21), '[NAK]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(22), '[SYN]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(23), '[ETB]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(24), '[CAN]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(25), '[EM]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(26), '[SUB]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(27), '[ESC]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(28), '[FS]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(29), '[GS]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(30), '[RS]')
--   SET @ShowWhiteSpace = REPLACE( @ShowWhiteSpace, CHAR(31), '[US]')
     RETURN(@ShowWhiteSpace)
END
SELECT dbo.ShowWhiteSpace(myfield) from mytable

 

Utilizar jquery ui con ASP .NET

Colocando esta linea de codigo funcionó los componentes de jquery ui con .NET

html aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AsistenteVentas.aspx.cs" Inherits="Mantenimientos.AsistenteVentas" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 <title></title>
 <link href="css/custom.css" rel="stylesheet" />
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
 <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css" />
 <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
</head>
 <script type="text/javascript">
 function InIEvent()
 {
 $(function () {
 var xdialog;
xdialog = $('#BuscaPersonal').dialog({
 modal: true,
 autoOpen: false,
 height: 300,
 width: 650
 });
$('#xbtn_buscar').on('click', function () {
 xdialog.dialog('open');
 $('#hddorigen').val('ASISTVTA');
 });
xdialog.parent().appendTo($('form:first'));
 });
 }
$(document).ready(InIEvent);
 
 </script>
<body>
 <form id="form1" runat="server">
 <asp:ScriptManager runat="server"></asp:ScriptManager>
 <script type="text/javascript">
 Sys.WebForms.PageRequestManager.getInstance().add_endRequest(InIEvent);
 </script>
 <div class="contenido">
 <h2>Asistentes de Ventas</h2>
 <div>
 <div>
 <table>
 <tr>
 <td> 
 <asp:ImageButton ID="btnNuevoAsisVta" runat="server" ImageUrl="~/img/nuevo.png" Width="16px" OnClick="btnNuevoAsisVta_Click" />
 </td>
 </tr>
 </table>
 </div>
 <%-- Panel de mantenimiento de asistentes de ventas --%>
 <asp:UpdatePanel ID="updpnlMtoAsistVta" runat="server" UpdateMode="Conditional">
 <ContentTemplate>
 <asp:Panel ID="pnlmtoAsistVta" runat="server">
 <table class="form-tabla">
 <tr>
 <td>Codigo</td>
 <td>:</td>
 <td><asp:TextBox ID="txtcodigoAsistvta" runat="server" ReadOnly="true" Width="50px"></asp:TextBox></td>
 <td><img src="img/search.png" width="32" alt="" id="xbtn_buscar" class="img-boton" /></td>
 </tr>
 <tr>
 <td>Nombres y Apellidos</td>
 <td>:</td>
 <td colspan="2"><asp:TextBox ID="txtnomyape" runat="server" ReadOnly="true" Width="200px"></asp:TextBox></td>
 </tr>
 <tr>
 <td>Correo Electrónico</td>
 <td>:</td>
 <td colspan="2"><asp:TextBox ID="txtcorreo" runat="server" ReadOnly="true" Width="200px"></asp:TextBox></td>
 </tr>
 <tr>
 <td>L&iacute;nea</td>
 <td>:</td>
 <td colspan="2"><asp:DropDownList ID="ddl_linea" runat="server" Width="150px"></asp:DropDownList></td>
 </tr>
 <tr class="form-fila-botones">
 <td colspan="2"><asp:ImageButton ID="btnguardarAsisVta" runat="server" ImageUrl="~/img/save.png" Width="32" /></td>
 <td colspan="2"><asp:ImageButton ID="btnregresarAsisVta" runat="server" ImageUrl="~/img/back.png" Width="32" OnClick="btnregresarAsisVta_Click" /></td>
 </tr>
 </table>
 <asp:Label ID="lblmensaje1" runat="server"></asp:Label>
 </asp:Panel>
 </ContentTemplate>
 <Triggers>
 <asp:AsyncPostBackTrigger ControlID="btnguardarAsisVta" EventName="Click" />
 <asp:AsyncPostBackTrigger ControlID="btnregresarAsisVta" EventName="Click" />
 <asp:AsyncPostBackTrigger ControlID="btnNuevoAsisVta" EventName="Click" />
 </Triggers>
 </asp:UpdatePanel>
<div> 
 <%-- Grilla de asistentes de ventas --%>
<asp:GridView ID="gvAsistentes" runat="server" AutoGenerateColumns="False">
 <Columns>
 <asp:TemplateField HeaderText="ID"> 
 <ItemTemplate>
 <asp:LinkButton ID="lnkID" runat="server" Text='<%# Eval("codigo").ToString() %>'></asp:LinkButton>
 </ItemTemplate>
 </asp:TemplateField>
 <asp:BoundField DataField="linea" HeaderText="Linea" />
 <asp:BoundField DataField="nombres" HeaderText="Nombres y Apellidos" />
 <asp:BoundField DataField="correo" HeaderText="Correo electronico" />
 <asp:TemplateField>
 <ItemTemplate>
 <asp:ImageButton ID="btneliminar" runat="server" ImageUrl="~/img/eliminar.png" Width="16" /> 
 </ItemTemplate>
 </asp:TemplateField>
 </Columns>
 </asp:GridView>
 </div>
 <div id="BuscaPersonal" class="widget" title="Busqueda de personal">
 <div>
 <%-- LA BUSQUEDA DE PERSONAL --%>
 <asp:Panel ID="pnl_buscar" runat="server" DefaultButton="btn_buscar">
 <table class="form-tabla">
 <tr>
 <td>Ingrese nombres o correo electrónico</td>
 <td>:</td>
 <td><asp:TextBox ID="txtbuscar" runat="server" Width="300px"></asp:TextBox></td>
 <td><asp:ImageButton ID="btn_buscar" runat="server" ImageUrl="~/img/search.png" Width="32" OnClick="btn_buscar_Click" /></td>
 </tr>
 </table> 
 </asp:Panel>
 </div>
 <asp:UpdatePanel ID="upd1" runat="server" UpdateMode="Conditional">
 <ContentTemplate>
 <asp:GridView ID="gvpersonal" runat="server" AutoGenerateColumns="False" CssClass="grid-net" >
 <Columns>
 <asp:TemplateField HeaderText="Codigo"> 
 <ItemTemplate>
 <asp:LinkButton ID="lnkpersonal" runat="server" Text='<%# Eval("CodigoPersona").ToString() %>'></asp:LinkButton>
 </ItemTemplate>
 </asp:TemplateField>
 <asp:BoundField DataField="NombresApellidos" HeaderText="Nombres y Apellidos" />
 <asp:BoundField DataField="CorreoElectronico" HeaderText="Correo electronico" />
 </Columns>
 </asp:GridView> 
 <asp:HiddenField ID="hddorigen" runat="server" /> 
 </ContentTemplate>
 <Triggers>
 <asp:AsyncPostBackTrigger ControlID="btn_buscar" EventName="Click" />
 </Triggers>
 </asp:UpdatePanel> 
 <div>
</div>
 </div>
<div>
 <%-- LA BUSQUEDA DE PERSONAL --%>
 <h3>Personal de Ventas</h3>
 <div>
 <table>
 <tr>
 <td><asp:ImageButton ID="img_nuevo_vta" runat="server" ImageUrl="~/img/nuevo.png" Width="16px" /></td>
 </tr>
 </table>
 </div>
 <div>
 <asp:GridView ID="gv_ventas" runat="server" AutoGenerateColumns="False">
 <Columns>
 <asp:BoundField DataField="codigo" HeaderText="Codigo" />
 <asp:BoundField DataField="nombres" HeaderText="Nombres y Apellidos" />
 <asp:BoundField DataField="correo" HeaderText="Correo electrónico" />
 <asp:TemplateField>
 <ItemTemplate>
 <asp:ImageButton ID="img_eliminar_vta" runat="server" ImageUrl="~/img/eliminar.png" Width="16px" />
 </ItemTemplate>
 </asp:TemplateField>
 </Columns>
 </asp:GridView>
 </div>
 </div>
 <div>
 <table>
 <tr>
 <td>
</td>
 </tr>
 </table>
 </div>
 </div>
 </div>
 </form>
</body>
</html>

Codigo C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DTO;
using ENT;

namespace Mantenimientos
{
 public partial class AsistenteVentas : System.Web.UI.Page
 {
 protected void Page_Load(object sender, EventArgs e)
 {
 if (!(Page.IsPostBack))
 {
 DTOAsistVta obj = new DTOAsistVta();
 List<ENTLinea> lstLinea = obj.ListarLineas();

 if (lstLinea.Count == 1 && lstLinea[0].Mensaje != null)
 {
 ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", string.Format("alert('Ha ocurrido un error: {0}", lstLinea[0].Mensaje), true);
 return;
 }

 this.ddl_linea.DataSource = lstLinea;
 this.ddl_linea.DataTextField = "NombreLinea";
 this.ddl_linea.DataValueField="CodigoLinea";
 this.DataBind();

 this.ddl_linea.Items.Insert(0, new ListItem("...Seleccione", "0"));
 //this.pnlmtoAsistVta.Style.Add(HtmlTextWriterStyle.Display, "none");
 this.pnlmtoAsistVta.Visible = false;
 }
 }

 protected void btn_buscar_Click(object sender, ImageClickEventArgs e)
 {
 DTOAsistVta obj = new DTOAsistVta();

 List<ENTPersona> lstpersona = obj.ListarColaboradores(this.txtbuscar.Text.Trim());
 
 //Verificando que no haya error

 if (lstpersona.Count == 1 && lstpersona[0].Mensaje != null)
 {
 ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", string.Format("alert('Ha ocurrido un error: {0}", lstpersona[0].Mensaje), true);
 return;
 }

 this.gvpersonal.DataSource = lstpersona;
 this.gvpersonal.DataBind();
 }

 protected void btnNuevoAsisVta_Click(object sender, ImageClickEventArgs e)
 {
 //this.pnlmtoAsistVta.Style.Add(HtmlTextWriterStyle.Display, "inline");
 this.pnlmtoAsistVta.Visible = true;
 }

 protected void btnregresarAsisVta_Click(object sender, ImageClickEventArgs e)
 {
 this.pnlmtoAsistVta.Visible = false;
 }


 }
}