Novo

Forum kao aplikacija na telefonu

Dodajte forum na početni ekran i koristite ga kao aplikaciju, sa menijem na dnu ekrana.

C# problem sacuvati HTML code u bazu podataka kao string

  • 5 odgovora
  • 3.961 pregleda

Najnovija ↓

C# problem sacuvati HTML code u bazu podataka kao string 11.01.2006. u 16:00 · pre 253 meseca
izmenjeno 1 put, poslednji put 01011011 11.01.2006. u 16:01
  1. 0101101111.01.2006. u 16:01zapis iz teksta poruke
#1
Evo ovako da malko oduzim. Koristim TinuMCE editor kod mene u programu i onda znaci izvlacim podatke iz baze podataka koji su zajedno sa html kodom u editor i onda editujem. Nakon toga sve to sto je editovano npr.

Code:
Advanced Clinical Services LLC has a one-year consulting opportunity for an <strong>RN</strong>
 who has a strong desire to transition their career into <strong>Drug Safety</strong>. Our client,
 located in the Northeast, is conducting clinical trials to study the last generation of analgesics, <strong>anesthetics</strong>,
 and other therapeutics to manage pain.<br />
As part of the Drug Safety and Pharmacovigilance Team, the Drug Safety Analyst is responsible for collecting, conducting follow-up, 
and entering the adverse information from all
 sources into the safety database. The work 
is done in accordance with FDA and ICH Regulations and Guidelines.<br /><br />


pokusavam da sacuvam u bazu podataka. Znaci sve to stavljam u string i onda trpam u bazu podataka. Dogadja mi se sledece da kad se prikazuje ovaj tekst na html stranici da se prikazuje bas ovako sa kodovima html koji su prikazani na stranici i nista nije formatirano, to jest ovako isto.

Code:
Advanced Clinical Services LLC has a one-year consulting opportunity for an <strong>RN</strong>
 who has a strong desire to transition their career into <strong>Drug Safety</strong>. Our client,
 located in the Northeast, is conducting clinical trials to study the last generation of analgesics, <strong>anesthetics</strong>,
 and other therapeutics to manage pain.<br />
As part of the Drug Safety and Pharmacovigilance Team, the Drug Safety Analyst is responsible for collecting, conducting follow-up, 
and entering the adverse information from all
 sources into the safety database. The work 
is done in accordance with FDA and ICH Regulations and Guidelines.<br /><br />


E sad, kako sacuvati ovo da bi mi se pokazalo poslije iz baze podataka kao normalno.


Hvala,
Re: C# problem sacuvati HTML code u bazu podataka kao string 11.01.2006. u 16:55 · pre 253 meseca
izmenjeno 1 put, poslednji put jablan 11.01.2006. u 16:57
  1. jablan11.01.2006. u 16:57zapis iz teksta poruke
#4
Pardon, u pitanju je statička metoda HttpUtility.HtmlDecode.

Baci pogled u help:
Citat:
The following example demonstrates the HtmlEncode and HtmlDecode methods of the HttpUtility class. The input string is taken from user and encoded using the HtmlEncode method.The encoded string thus obtained is then decoded using the HtmlDecode method.

[Visual Basic, C#] Note This example shows how to use one of the overloaded versions of HtmlDecode. For other examples that might be available, see the individual overload topics.

[C#]
using System;
using System.Web;
using System.IO;

class MyNewClass
{
public static void Main()
{
String myString;
Console.WriteLine("Enter a string having '&' or '\"' in it: ");
myString=Console.ReadLine();
String myEncodedString;
// Encode the string.
myEncodedString = HttpUtility.HtmlEncode(myString);
Console.WriteLine("HTML Encoded string is "+myEncodedString);
StringWriter myWriter = new StringWriter();
// Decode the encoded string.
HttpUtility.HtmlDecode(myEncodedString, myWriter);
Console.Write("Decoded string of the above encoded string is "+
myWriter.ToString());
}
}

Re: C# problem sacuvati HTML code u bazu podataka kao string 11.01.2006. u 17:48 · pre 253 meseca
izmenjeno 1 put, poslednji put 01011011 11.01.2006. u 17:49
  1. 0101101111.01.2006. u 17:49zapis iz teksta poruke
#5
Ne kontam kako da ovo iskoristim...

Evo ovako...

Prvo povlacim polje iz baze podataka
Code:
string longD = (ds.Tables[0].Rows[0]["Description"].ToString().Trim());

                if  ( longD != "" )
                {
                    description_text.Value = longD;
                    
                }


Nakon toga se rade promjene i sacuvavam promjene u string

Code:
string description = description_text.Value.ToString().Trim();



e sada kad uradim ovo da testiram description mi je ovako...

Code:
<em><strong><strong>Advanced Clinical Services LLC has a one-year consulting opportunity for an RN who <br /></strong>



znaci dobro je, ali kad ga saqacuvam u bazu podataka onda se sacuva kao ovo

Code:
&lt;strong&gt;Advanced Clinical Services LLC has a one-year consulting opportunity for an RN who&lt;/strong&gt;



E sada ja zelim da se ona sacuva u orginalnom obliku... kako ovo da izvedem?>
Re: C# problem sacuvati HTML code u bazu podataka kao string 11.01.2006. u 18:11 · pre 253 meseca #6
Skontao sam...Hvala mnogo na pomoci :)

Code:

string description1 = description_text.Value.ToString().Trim();

                    StringWriter myWriter = new StringWriter();
                    // Decode the encoded string.
                    HttpUtility.HtmlDecode(description1, myWriter);

                    string description = myWriter.ToString();


Prijavite se da biste odgovorili u ovoj temi.PrijavaRegistracija

Premeštanje teme