Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

PauloCastilho

@PauloCastilho
About
Posts
17
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Encrypt text
    P PauloCastilho

    Use this class...

    public class Rijndael
    {
    public static string Encrypt(string text, string key)
    {
    RijndaelManaged rijndael = new RijndaelManaged();

        byte\[\] plainText = System.Text.Encoding.Unicode.GetBytes(text);
    
        byte\[\] salt = Encoding.ASCII.GetBytes(key.Length.ToString());
    
        PasswordDeriveBytes secretKey = new PasswordDeriveBytes(key, salt);
    
        ICryptoTransform Encryptor = rijndael.CreateEncryptor(secretKey.GetBytes(32), secretKey.GetBytes(16));
    
        MemoryStream memoryStream = new MemoryStream();
    
        CryptoStream cryptoStream = new CryptoStream(memoryStream, Encryptor, CryptoStreamMode.Write);
    
        cryptoStream.Write(plainText, 0, plainText.Length);
    
        cryptoStream.FlushFinalBlock();
    
        byte\[\] cipherBytes = memoryStream.ToArray();
    
        memoryStream.Close();
        cryptoStream.Close();
    
        return Convert.ToBase64String(cipherBytes);
    }
    
    public static string Decrypt(string text, string key)
    {
        RijndaelManaged rijndael = new RijndaelManaged();
    
        byte\[\] encryptedText = Convert.FromBase64String(text);
    
        byte\[\] salt = Encoding.ASCII.GetBytes(key.Length.ToString());
    
        PasswordDeriveBytes secretKey = new PasswordDeriveBytes(key, salt);
    
        ICryptoTransform Decryptor = rijndael.CreateDecryptor(secretKey.GetBytes(32), secretKey.GetBytes(16));
    
        MemoryStream memoryStream = new MemoryStream(encryptedText);
    
        CryptoStream cryptoStream = new CryptoStream(memoryStream, Decryptor, CryptoStreamMode.Read);
    
        byte\[\] plainText = new byte\[encryptedText.Length\];
    
        int DecryptedCount = cryptoStream.Read(plainText, 0, plainText.Length);
    
        memoryStream.Close();
        cryptoStream.Close();
    
        return Encoding.Unicode.GetString(plainText, 0, DecryptedCount);
    }
    

    }

    e.g.

    TextBox2.Text = Rijndael.Encrypt(TextBox1.Text, "SecurityKey");
    TextBox3.Text = Rijndael.Decrypt(TextBox2.Text, "SecurityKey");

    modified on Wednesday, August 26, 2009 10:46 AM

    ASP.NET csharp asp-net tutorial question

  • Gridview empty
    P PauloCastilho

    DotNetXenon wrote:

    How to set Gridview.Datasource = empty?

    Don´t set. Just call Gridview.DataBind(); and your GridView will be empty.

    DotNetXenon wrote:

    How to show a message inside the gridview like "No records" in C#?

    Before calling Gridview.DataBind();, set Gridview.EmptyDataText = "No records";

    Web Development csharp tutorial question

  • Val function in vb.net problem
    P PauloCastilho

    Instead of Val(), use Convert.ToInt32() or Convert.ToDouble().

    Dim value as Double = Convert.ToInt32(Request.QueryString("val") & "0")

    or

    Dim value as Double = Convert.ToDouble(Request.QueryString("val") & "0")

    ASP.NET csharp help question

  • Regex for MM/YYYY date format
    P PauloCastilho

    Regex: \d{2}\/\d{4} Code:

    public static bool IsDate(string date)
    {
    return Regex.IsMatch(date, @"^(\d{2}\/\d{4})$");
    }

    C# regex help

  • Generating site "posts"
    P PauloCastilho

    Use asp.net repeater control.

    <asp:Repeater id="rPOSTS" runat="server">
    <ItemTemplate>
    </ItemTemplate>
    asp:Repeater

    On ItemTemplate you will put the code you want to repeat X times. So, in code behind you will do something like this: rPOSTS.DataSouce = YOUR_DB_DATA; rPOSTS.DataBind(); See more about repeater control in Google[^].

    ASP.NET database

  • Design issue---SEO activities
    P PauloCastilho

    For a better result, generate a single url for each content. eg. www.yoururl.com/topic1, www.yoururl.com/topic2 ... In this case, you will have one unique page that receives parameters and "generate" the page. How? Using URL Rewrite. With one page, you can "make" many others. ;) And... In addition to meta tags, set a unique title too.

    Web Development html database design security help

  • how to copy a file machine A into Machine B
    P PauloCastilho

    If the machines are in the same network, all you have to do is grant write permission to ASPNET user on the destination folder.

    Web Development csharp asp-net sysadmin tutorial

  • SQL SCRIPT
    P PauloCastilho

    It´s very hard to rewrite a SQL query that I didn´t know the schema and relationships. Anyway, I made some changes.

    kibromg wrote:

    select count(distinct(CR_Cli))

    Verify if the column has an index.

    kibromg wrote:

    datename(month,cr_callstart)='April'

    Do not use much functions on where clause. Simplify... use "month(CR.callstart) = 4".

    kibromg wrote:

    and Cr_cli not in (select Cr_cli from Callrecords where cr_callstart<'2009-03-31')

    If Cr_Cli "not in" where cr_callstart < '2009-03-31 then Cr_Cli "is in" where cr_callstart > '2009-03-30'. More than that, you are already referencing Callrecords in inner join, so you don´t need to create a subselect. On where clause, use this condition: "CR.callstart > '2009-03-30'".

    kibromg wrote:

    group by SO_name desc

    On group by you have the column SO_name. Does this column have an index?! If not, you must consider creating one. Try the code below, maybe it helps. select count(distinct(CR.Cli)) , SO.name from Callrecords CR inner join StudioOperators SO on CR.StudioOperatorID = SO.ID where month(CR.callstart) = 4 and CR.callstart > '2009-03-30' group by SO.name desc

    C# database tools help question

  • Convert
    P PauloCastilho

    Try this: pattern.WhichWeek = (ReportWS.WeekNumberEnum)System.Enum.Parse(typeof(ReportWS.WeekNumberEnum), Combobox1.SelectedItem.Value);

    C# csharp regex help tutorial

  • How to add items in listbox from database
    P PauloCastilho

    Try to use this two properties: DataValueField and DataTextField. e.g. //SOURCE_FROM_DB -> The method or object or ... whatever ... that has the items. myListBox.DataSouce = SOURCE_FROM_DB; //VALUE_COLUMN_NAME -> The column name of the DataSource that represents the VALUE of the item. myListBox.DataValueField = "VALUE_COLUMN_NAME"; //TEXT_COLUMN_NAME -> The column name of the DataSource that represents the TEXT of the item. myListBox.DataTextField = "TEXT_COLUMN_NAME"; myListBox.DataBind();

    C# database tutorial

  • Link button problem
    P PauloCastilho

    LinkButton is an ASP.Net Server Control that generates an html anchor tag ( <a></a> ) with a JavaScript similiar to "javascript:__doPostBack('','')" in href attribute. So, if you try to "Open in new window", you will obviously get an error because you are trying to open an JavaScript command in a new window.

    ASP.NET help question

  • 070-536 preparation tests
    P PauloCastilho

    I have the same material. It´s enough to pass. :thumbsup: As my friend said: "Study the Actual Tests. Just use the book if you are curious to discover why the answer is right." :laugh:

    .NET (Core and Framework) announcement

  • How to access the changes in style.display property by Javascript in code behind
    P PauloCastilho

    Why don´t you use asp:panel instead of <div>? The Panel control generate the same code ( <div></div> ) and can be manipulated in code behind.

    modified on Friday, April 17, 2009 6:11 PM

    ASP.NET java javascript sysadmin tools tutorial

  • JSON
    P PauloCastilho

    JSON is an acronym to JavaScript Object Notation. It is a lightweight data-interchange format. Can be used as an alternative to XML. In asp.net, you can use JSON as a data-interchanger format with AJAX using DataContractJsonSerializer.

    ASP.NET question csharp asp-net json

  • Hide/Show Div when selecting radio button
    P PauloCastilho

    You can do it just using JavaScript. Download jQuery 1.3.2[^] and test the code below. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>DIV show / hide example</title> <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#box_dv div').each(function() { $(this).hide(); }); $('#box_rdo input:radio').each(function() { $(this).click(function() { $('#box_dv div').hide(); $('#' + $(this).attr('value')).show(); }); }) }); </script> </head> <body> <div> <div id="box_rdo"> <input type="radio" id="r1" name="rdo" value="d1" /><label for="r1">DIV 1</label> <input type="radio" id="r2" name="rdo" value="d2" /><label for="r2">DIV 2</label> </div> <br /> <div id="box_dv"> <div id="d1"> <h1>DIV 1</h1> This is the DIV 1 content! </div> <div id="d2"> <h1>DIV 2</h1> This is the DIV 2 content! </div> </div> </div> </body> </html> If you gonna use asp.net server controls, instead of <input type="radio"> and <div> use asp:RadioButtonList and asp:Panel... Handle the OnSelectedIndexChanged event of the radio button list to manipulate the visibility of the asp:panel's (div's).

    modified on Monday, April 6, 2009 12:47 PM

    ASP.NET

  • Can't send mail on localhost
    P PauloCastilho

    Creamboy wrote:

    mailMsg.From = new MailAddress("localhost", "Webmaster"); mailMsg.To.Add(new MailAddress("localhost", "Client guy"));

    Change "localhost" to a valid email address.

    ASP.NET

  • System.Net.Mail setup
    P PauloCastilho

    System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient([Host], [Port]);
    smtp.Credentials = new System.Net.NetworkCredential([UserName], [Password]);

    If you prefer, use the config file (web.config, app.config).

    <system.net>
    <mailSettings>
    <smtp>
    <network host="" port="" userName="" password="" />
    </smtp>
    </mailSettings>
    </system.net>

    C# csharp tutorial question workspace
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups