Abolfazl

Abolfazl

  • NA
  • 184
  • 81.5k

how to convert a illegible string to legible string?

Jun 9 2014 6:01 AM
hi
i want to convert a illegible string to legible.i try this code: 
 
string encoded_text = richTextBox1.Text;
string decoded_text;
byte[] b = System.Text.Encoding.Default.GetBytes(encoded_text);
decoded_text = System.Text.Encoding.UTF8.GetString(b);
richTextBox2.Text = decoded_text;
 
but when i convert encoded_text just show ? in richtextbox2.
can you help me?
 
 you can download my project by this link: download my project
 
thanks 

Answers (1)

0
Satyapriya Nayak

Satyapriya Nayak

  • 0
  • 39.3k
  • 13.3m
Aug 11 2011 2:54 PM
Hi kieky,

If this post helps you mark it as answer

Thanks
0
Satyapriya Nayak

Satyapriya Nayak

  • 0
  • 39.3k
  • 13.3m
Aug 10 2011 2:28 PM

Attachment: listview.rar

Hi kieky,
Use the below code and run the attachments.

Default.aspx code

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>Listview</title>
</head>
<body>
  <form id="form1" runat="server">
  <div>
  <asp:ListView ID="ListView1" runat="server" DataKeyNames="sid"
  OnSelectedIndexChanging="ListView1_SelectedIndexChanging">
 
  <LayoutTemplate>
  <table style="border: solid 2px red;" cellspacing="0" cellpadding="3" rules="all">
  <tr style="background-color: red; color: Yellow;">
  <th>Select</th>
  <th>Student ID</th>
  <th>Student Name</th>
  <th>Student Address</th>
  <th>Student Marks</th>
  </tr>
  <tbody>
  <asp:PlaceHolder ID="itemPlaceHolder" runat="server" />
  </tbody>
  </table>
  </LayoutTemplate>
 
 
  <ItemTemplate>
  <tr>
  <td>
  <asp:LinkButton ID="lnkSelect" Text="Select" CommandName="Select" runat="server" />
  </td>
  <td><%#Eval("sid")%></td>
  <td><%#Eval("sname")%></td>
  <td><%#Eval("saddress")%></td>
  <td><%#Eval("smarks")%></td>
  </tr>
  </ItemTemplate>
  <SelectedItemTemplate>
  <tr style="background-color: Yellow; color: Green;">
  <td>
  <asp:LinkButton ID="lnkSelect" Text="Select" CommandName="Select" runat="server"
  ForeColor="Blue" />
  </td>
  <td><%#Eval("sid")%></td>
  <td><%#Eval("sname")%></td>
  <td><%#Eval("saddress")%></td>
  <td><%#Eval("smarks")%></td>
  </tr>
  </SelectedItemTemplate>
</asp:ListView>

<br />
<asp:Label ID="Label1" runat="server"></asp:Label>
  </div>
  </form>
</body>
</html>

Default.aspx.vb code

Imports System.Data.SqlClient
Imports System.Data
Partial Class _Default
    Inherits System.Web.UI.Page
    Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ToString()
    Dim con As New SqlConnection(strConnString)
    Dim sqlda As SqlDataAdapter
    Dim com As SqlCommand
    Dim ds As DataSet
    Dim str As String
    Dim str1 As String
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        binddata()
    End Sub

    Sub binddata()
        con.Open()
        str = "select * from student"
        com = New SqlCommand(str, con)
        sqlda = New SqlDataAdapter(com)
        ds = New DataSet()
        sqlda.Fill(ds, "student")
        ListView1.DataSource = ds
        ListView1.DataMember = "student"
        ListView1.DataBind()
        con.Close()
    End Sub

    Protected Sub ListView1_SelectedIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewSelectEventArgs) Handles ListView1.SelectedIndexChanging
        ListView1.SelectedIndex = e.NewSelectedIndex
        str1 = ListView1.SelectedDataKey.Value
        Label1.Text = "<b>You have selected Student ID:</b>" & str1
        binddata()
    End Sub
End Class



Thanks
If this post helps you mark it as answer
0
Satyapriya Nayak

Satyapriya Nayak

  • 0
  • 39.3k
  • 13.3m
Aug 10 2011 2:08 PM
Hi kieky,
Use the below code and run the attachments.


Default.aspx code

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:ListView ID="ListView1" runat="server" DataKeyNames="sid"
   OnSelectedIndexChanging="ListView1_SelectedIndexChanging">
   
   <LayoutTemplate>
      <table style="border: solid 2px red;" cellspacing="0" cellpadding="3" rules="all">
         <tr style="background-color: red; color: Yellow;">
            <th>Select</th>
            <th>Student ID</th>
            <th>Student Name</th>
            <th>Student Address</th>
            <th>Student Marks</th>
         </tr>
         <tbody>
            <asp:PlaceHolder ID="itemPlaceHolder" runat="server" />
         </tbody>
      </table>
   </LayoutTemplate>
 
  
   <ItemTemplate>
      <tr>
         <td>
            <asp:LinkButton ID="lnkSelect" Text="Select" CommandName="Select" runat="server" />
         </td>
         <td><%#Eval("sid")%></td>
         <td><%#Eval("sname")%></td>
         <td><%#Eval("saddress")%></td>
         <td><%#Eval("smarks")%></td>
      </tr>
   </ItemTemplate>
   <SelectedItemTemplate>
      <tr style="background-color: Yellow; color: Green;">
         <td>
            <asp:LinkButton ID="lnkSelect" Text="Select" CommandName="Select" runat="server"
               ForeColor="Blue" />
         </td>
         <td><%#Eval("sid")%></td>
         <td><%#Eval("sname")%></td>
         <td><%#Eval("saddress")%></td>
         <td><%#Eval("smarks")%></td>
      </tr>
   </SelectedItemTemplate>
</asp:ListView>

<br />
<asp:Label ID="Label1" runat="server"></asp:Label>
    </div>
    </form>
</body>
</html>

Default.aspx.cs code
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
    string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
    DataSet ds = new DataSet();
    SqlCommand com;
    SqlConnection con;
    SqlDataAdapter sqlda;
    string str;
    string str1;
    protected void Page_Load(object sender, EventArgs e)
    {
        binddata();
    }
    void binddata()
    {
        con = new SqlConnection(connStr);
        con.Open();
        str = "select * from student";
        com = new SqlCommand(str, con);
        sqlda = new SqlDataAdapter(com);
        ds = new DataSet();
        sqlda.Fill(ds, "student");
        ListView1.DataSource = ds;
        ListView1.DataMember = "student";
        ListView1.DataBind();
        con.Close();
    }
    protected void ListView1_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
    {
        ListView1.SelectedIndex =Convert.ToInt32(e.NewSelectedIndex);
        str1 = ListView1.SelectedDataKey.Value.ToString();
        Label1.Text = "<b>You have selected Student ID:</b>" + str1;
        binddata();
    }
}



Thanks
If this post helps you mark it as answer
0
Vilas Gite

Vilas Gite

  • 525
  • 2.5k
  • 543.5k
Aug 10 2011 10:06 AM
Hi Kieky...
Refer 'Our recommended articles"
 
---------------------------------