April 2008 - Posts

Avoiding Spam Filter on Sending HTML Mail

 Hi guys, it's me your host.

is there a moment in your life where you want to send emails, but want to avoid being blocked by Spam Filter on Destination Mail server .

hey there's some tricks come in rescue which i also experienced.

you see you've to make Two kinds of alternate view, one for view as plain text the other is HTML.

System.Net.Mail.MailMassage

                    d.Email.AlternateViews.Clear();
                    HtmlFile ConverterHtml = new HtmlFile(pathtowrite+ "temp.html");
                    d.Email.AlternateViews.Add(ConverterHtml.ConvertToMIME());
                    System.Net.Mail.AlternateView plainView = System.Net.Mail.AlternateView.CreateAlternateViewFromString
                    (System.Text.RegularExpressions.Regex.Replace(hasilhtml, @"<(.|\n)*?>", string.Empty), null, "text/plain");
                    d.Email.AlternateViews.Add(plainView);
                    d.MailTo = penerima.email;

 and they just loved it and let you pass.

Chiao

Share this post: | | | |
Posted by cipto with 1 comment(s)
Filed under:

Using Generic Handler and Ultrawebgrid To display Images

 It's early in the morning. Morning to you all.

Now, i want to discuss about displaying images on our grid. Ok , you've got application that store the data in binary on Your DB . and then you need to display it on your grid row by row.

ultrawebgrid,Grid can have template column that host asp control and of course asp:image

1.add this on your webgrid

<igtbl:TemplatedColumn BaseColumnName="ImagePreview" Key="ImagePreview" IsBound="True">
                                                         <Header Caption="Imagephoto">
                                                         <RowLayoutColumnInfo OriginX="1" />
                                                         </Header>
                                                         <Footer>
                                                         <RowLayoutColumnInfo OriginX="1" />
                                                         </Footer>
                                                         <CellTemplate>
                                                         <asp:Image runat="server" ID="image1" ImageUrl="<%# Container.Value %>" />
                                                         </CellTemplate>
                                                        </igtbl:TemplatedColumn>

2.Add a httphandler(generic handler) for streaming, ashx is very nice for custom streaming, and aspx is good at streaming html.

 <%@ WebHandler Language="C#" Class="imgstrm" %>

using System;
using System.Web;
using System.Linq;

public class imgstrm : System.Web.IHttpHandler {
    

    public void ProcessRequest (HttpContext context) {
        string id=context.Request.QueryString["id"];
        StreamImage(id, context.Response);
    }
 
    private void StreamImage(string id, HttpResponse response)
    {
        using (MTSDataContext a = new MTSDataContext())
        {
            Collateral theonewesearch = (from temp in a.Collaterals
                                         where temp.ID == id.Trim()
                                         select temp).First();

          using(System.IO.MemoryStream stream = new System.IO.MemoryStream(theonewesearch.Image.ToArray()))
          {

              System.Drawing.Image image = System.Drawing.Image.FromStream(stream);
              byte[] data = theonewesearch.Image.ToArray();
              response.ContentType = "image/jpeg";
              System.Drawing.Bitmap fullbitmap = new System.Drawing.Bitmap(image);
              fullbitmap.Save(response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);     
              response.Flush();
              response.End();
        }
        }
    }
    public bool IsReusable {
        get {
            return true;
        }
    }

}

add on your Data source , change the select query

3. SELECT [ID], [Type], [Description], [Priority],'imgstrm.ashx?id=' + CAST([ID] AS Varchar(16)) as  [ImagePreview]  FROM [Collateral]

and Wualah, and some magic word sim sa labim press F5 , it appears

 

 

Share this post: | | | |
Posted by cipto with no comments
Filed under:

VlinQ Builder

I've download and install and try to use this builder, it's a builder for building query, and put it on bag.

and when you want to use it. it's already make as a Class. For ex: Class1.

You can then use it as : var hasil = Class1.Getsomething.

you can choose as compiled query or not.

but what i exprienced is when i want to compare this field with null (system.type) it can not the ide just won't receive anything beside the parameter of the function.

 

 

Share this post: | | | |
Posted by cipto with no comments
Filed under:

PostgreSqlmembership provider dan Postgresqlroleprovider

 Hi,

Perhaps u are one of person who meets the same case like me.

We want to provide membersip but the DB is on Postgre how to do it?

We create our own provider by inherit the Membershiprovider and roleprovider respectively.

we override the necessary function

 Did i get it from other person? Yes, but i change abit cause there's some issue

 private MembershipUser GetUserFromReader(NpgsqlDataReader reader)
        {
                object providerUserKey = reader.HasRows? new Guid(reader.GetValue(0).ToString()) : new Guid();
                string username = reader.HasRows ? reader.GetString(1) : "";
                string email = reader.HasRows ? reader.GetString(2) : "" ;
                string passwordQuestion = reader.HasRows ? reader.GetString(3) : ""  ;
                string comment = reader.HasRows ? reader.GetString(4) : "" ;
                bool isApproved = reader.HasRows ? reader.GetBoolean(5) :false ;
                bool isLockedOut = reader.HasRows ? reader.GetBoolean(6):false ;
                DateTime creationDate = reader.HasRows ? reader.GetDateTime(7):DateTime.Now  ;
                DateTime lastLoginDate = reader.HasRows ? reader.GetDateTime(8):DateTime.Now ;
                DateTime lastActivityDate = reader.HasRows ? reader.GetDateTime(9) :DateTime.Now  ;
                DateTime lastPasswordChangedDate = reader.HasRows ? reader.GetDateTime(10) :DateTime.Now  ;
                DateTime lastLockedOutDate = reader.HasRows ? reader.GetDateTime(11): DateTime.Now  ;
                return new MembershipUser(
                    this.Name,
                    username,
                    providerUserKey,
                    email,
                    passwordQuestion,
                    comment,
                    isApproved,
                    isLockedOut,
                    creationDate,
                    lastLoginDate,
                    lastActivityDate,
                    lastPasswordChangedDate,
                    lastLockedOutDate
                    );
            }

 

 private bool validatePassword(string password, string dbpassword, string salt)
        {
            switch (PasswordFormat)
            {
                case MembershipPasswordFormat.Encrypted:
                    return password == UnEncodePassword(dbpassword);
                case MembershipPasswordFormat.Hashed:
                    return dbpassword == encodePassword(password, salt);
                case MembershipPasswordFormat.Clear:
                    return password == dbpassword;
         
       default:
                    return false;
            }
        }

on web.config

add

<connectionStrings>
        <add name="postgresqlConnString" connectionString="DATABASE=postgres;SERVER=localhost;PORT=5432;UID=cipto;Password=200382"/>
    </connectionStrings>


<authentication mode="Forms">
            <!--<forms loginUrl="~/login.aspx" defaultUrl="~/Default.aspx" name=".ASPXFORMSAUTH"/>-->
        </authentication>
        <roleManager defaultProvider="PostgreSqlRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".ASPROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All">
            <providers>
                <clear/>
                <add name="PostgreSqlRoleProvider" connectionStringName="postgresqlConnString" applicationName="YOURAPPNAME" type="Andri.Web.PostgreSqlRoleProvider"/>
            </providers>
        </roleManager>
        <membership defaultProvider="PostgreSqlMembershipProvider">
            <providers>
                <clear/>
                <add connectionStringName="postgresqlConnString" applicationName="YOURAPPNAME" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Clear" name="PostgreSqlMembershipProvider" encryptionKey="AB56FE8EA700B42A" type="Andri.Web.PostgreSqlMembershipProvider"/>
            </providers>
        </membership>under the configuration tag.

 

   

Postgremembership.zip 

Share this post: | | | |
Posted by cipto with no comments
Filed under:

ultrawebgrid when bind to source and set initilize layout event, shows white row

When trying to style the UltraWebGrid’s Header using CSS, that CSS will be applied to the WebGrid’s rows as well as its Header. This behavior is caused by the way the WebGrid optimizes its HTML output. To work around this designed behavior, you can set the WebGrid’s DisplayLayout.OptimizeCSSClassNamesOutput to False. so just add e.Layout.OptimizeCSSClassNamesOutput = Infragistics.WebUI.Shared.DefaultableBoolean.False; on initilize layout event

Share this post: | | | |
Posted by cipto with no comments
Filed under:

Infragistics how to show ultrawebgrid edit template

ultrawebgrid punya suatu fitur untuk menampilkan suatu form bila user mengedit  lalu ada button ok dan cancel

bagaimana cara memunculkannya?

 

protected void GridViewRTSH_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e)
    {
       
        // Allow users to edit the data in the grid but only via a drop down template on the row
        e.Layout.Bands[0].AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.RowTemplateOnly;
        // Go into edit mode as soon as a user enters a cell. This allows for fast data entry
        e.Layout.Bands[0].CellClickAction = Infragistics.WebUI.UltraWebGrid.CellClickAction.Edit;

    }

Share this post: | | | |
Posted by cipto with no comments
Filed under:

Javascript suka gak jalan/terdetect kalau tambah di master page

 whuah , ini lagi satu

g tambah di master page gak ke detect di UI infragistic nya.

solusinya gue Page.RegisterClientScriptBlock

 

Share this post: | | | |
Posted by cipto with no comments
Filed under:

vs2008 buka aspx ,keluar error opening document, juga gak muncul di designer, terus ada pop up document too long

whuahh,

ini dia nich

pokoknya g tuch paling males kalo ketemu bug2 dari vs

ternyata setelah g liat entah ini salah dari control atau apa yang gue masukin

ada karakter aneh kotak2 panjang, ini yang bikin rusak

g hapus jalan lagi. 

Share this post: | | | |
Posted by cipto with no comments
Filed under:

Vs2008 Lambat buka designer dan parsing Xhtml

whuah, baru bisa ngeblog lagi

guys update vs2008 anda, karena lambat sekali dalam parsing nya

VS90-KB946581.exe 

Share this post: | | | |
Posted by cipto with no comments
Filed under: