tag:blogger.com,1999:blog-50775675274476310692023-11-15T09:13:40.549-08:00DotNet-IntelligentImrankhan Pathanhttp://www.blogger.com/profile/00481180443247674321noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-5077567527447631069.post-42597841529766870642008-07-24T23:46:00.000-07:002008-07-24T23:51:38.138-07:00Outline border on Text using GDI+<span style="font-weight:bold;">Outline Border On Text Using GDI+</span><br /><br />string text="Welcome to Asp.Net";<br />string fontFamily = "Impact";<br />float fontSize = 200;<br />bool fontBold = true;<br />bool fontItalic = true;<br />bool fontUnderline = false;<br />Color fontColor ="#FF0000";<br />Color b_Color ="#00FF00"; // Border Color<br />int BlurAmt =9;<br />SizeF size = new SizeF();<br />Font font = null;<br />Bitmap bitmap = new Bitmap(1, 1);<br />Graphics g = Graphics.FromImage(bitmap);<br /><br />g.PixelOffsetMode = PixelOffsetMode.HighQuality;<br />g.TextRenderingHint = TextRenderingHint.AntiAlias;<br />g.SmoothingMode = SmoothingMode.HighQuality;<br /><br /><br />FontStyle fontStyle = FontStyle.Regular;<br />if (fontBold) fontStyle |= FontStyle.Bold;<br />if (fontItalic) fontStyle |= FontStyle.Italic;<br />if (fontUnderline) fontStyle |= FontStyle.Underline;<br /><br />font = new Font(fontFamily, fontSize, fontStyle,GraphicsUnit.Pixel);<br />StringFormat sf = new StringFormat();<br /> <br />sf.Alignment = StringAlignment.Near;<br />sf.FormatFlags = StringFormatFlags.DisplayFormatControl;<br />sf.LineAlignment = StringAlignment.Near;<br />sf.Trimming = StringTrimming.Word;<br />size = g.MeasureString(text, font,new PointF(0,0),sf);<br />bitmap = new Bitmap((int)size.Width , (int)size.Height ,PixelFormat.Format32bppPArgb);<br /><br />g = Graphics.FromImage(bitmap);<br />g.Clear(Color.Transparent);<br /><br />sf.Trimming = StringTrimming.None;<br />g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;<br />g.SmoothingMode = SmoothingMode.HighQuality;<br />g.InterpolationMode = InterpolationMode.HighQualityBilinear;<br />g.CompositingQuality = CompositingQuality.HighQuality;<br />g.PixelOffsetMode = PixelOffsetMode.HighQuality;<br /><br />GraphicsUnit gUnit = GraphicsUnit.Pixel;<br /> <br />SolidBrush br = new SolidBrush(Color.White);<br /> <br />//LinearGradientBrush br = new LinearGradientBrush(new RectangleF(0, 0, size.Width, size.Height), Color.Red, Color.Yellow, LinearGradientMode.Horizontal);<br /> <br />br = new SolidBrush(fontColor);<br />SolidBrush b_color = new SolidBrush(Color.White);<br />b_color = new SolidBrush(b_Color);<br />for (int x = 0; x <= BlurAmt; x++)<br />{<br /> for (int y = 0; y <= BlurAmt; y++)<br /> {<br /> g.DrawString(text, font, b_color, new Point(x, y), sf);<br /> }<br />}<br />g.DrawString(text, font, br, new Point(BlurAmt / 2 , BlurAmt / 2 ), sf);<br /> <br />MemoryStream m = new MemoryStream();<br /><br />bitmap.Save(m, ImageFormat.Png);<br />m.WriteTo(Response.OutputStream);Imrankhan Pathanhttp://www.blogger.com/profile/00481180443247674321noreply@blogger.com2tag:blogger.com,1999:blog-5077567527447631069.post-46786251631912364822008-03-18T00:27:00.000-07:002008-03-18T00:35:44.793-07:00Rotate Imageprotected void Page_Load(object sender, EventArgs e)<br /> {<br /> Bitmap b = new Bitmap(Server.MapPath("3.jpg"));<br /> b = RotateBitmap(45, b);<br /> b.Save(Server.MapPath("6.jpg"), ImageFormat.Jpeg);<br /> }<br /> public Bitmap RotateBitmap(float Angle, Bitmap bm_in)<br /> {<br /> try<br /> {<br /> float wid = bm_in.Width;<br /> float hgt = bm_in.Height;<br /> Point[] corners = { new Point(0, 0), new Point(int.Parse(wid.ToString()), 0), new Point(0, int.Parse(hgt.ToString())), new Point(int.Parse(wid.ToString()), int.Parse(hgt.ToString())) };<br /> int cx = int.Parse(wid.ToString()) / 2;<br /> int cy = int.Parse(hgt.ToString()) / 2;<br /> long i;<br /> for (i = 0; i <= 3; i++)<br /> {<br /> corners[i].X -= Convert.ToInt32(cx.ToString());<br /> corners[i].Y -= Convert.ToInt32(cy.ToString());<br /> }<br /><br /> float theta = (float)(Angle * Math.PI / 180.0);<br /> float sin_theta = (float)Math.Sin(theta);<br /> float cos_theta = (float)Math.Cos(theta);<br /> float X;<br /> float Y;<br /> for (i = 0; i <= 3; i++)<br /> {<br /> X = corners[i].X;<br /> Y = corners[i].Y;<br /> corners[i].X = (int)(X * cos_theta + Y * sin_theta);<br /> corners[i].Y = (int)(-X * sin_theta + Y * cos_theta);<br /> }<br /><br /> float xmin = corners[0].X;<br /> float ymin = corners[0].Y;<br /> for (i = 1; i <= 3; i++)<br /> {<br /> if (xmin > corners[i].X)<br /> xmin = corners[i].X;<br /> if (ymin > corners[i].Y)<br /> ymin = corners[i].Y;<br /> }<br /> for (i = 0; i <= 3; i++)<br /> {<br /> corners[i].X -= int.Parse(xmin.ToString());<br /> corners[i].Y -= int.Parse(ymin.ToString());<br /> }<br /><br /> Bitmap bm_out = new Bitmap((int)(-2 * xmin), (int)(-2 * ymin));<br /> Graphics gr_out = Graphics.FromImage(bm_out);<br /> // ERROR: Not supported in C#: ReDimStatement<br /> Point[] temp = new Point[3];<br /> if (corners != null)<br /> {<br /> Array.Copy(corners, temp, Math.Min(corners.Length, temp.Length));<br /> }<br /> corners = temp;<br /> gr_out.DrawImage(bm_in, corners);<br /> return bm_out;<br /> }<br /> catch (Exception ex)<br /> {<br /> string s = ex.Message;<br /> return bm_in;<br /> }<br /> }Imrankhan Pathanhttp://www.blogger.com/profile/00481180443247674321noreply@blogger.com2tag:blogger.com,1999:blog-5077567527447631069.post-40769103441356066952007-11-02T03:27:00.000-07:002007-11-02T03:34:42.540-07:00Tell a friend : Custom Controlusing System;<br /> using System.Collections.Generic;<br /> using System.ComponentModel;<br /> using System.Text;<br /> using System.Web;<br /> using System.Web.UI;<br /> using System.Web.UI.WebControls;<br /> using System.Diagnostics;<br /> using System.IO;<br /> using System.Data;<br /> using System.Web.UI.Design;<br /> using System.Web.UI.HtmlControls;<br /> using System.Net.Mail;<br />namespace ccc.TellaFriend<br />{<br /> public enum TellaFreindText<br /> {<br /> Your_Name=0,<br /> Your_Email=1,<br /> Friend_Email=2,<br /> Message=3,<br /> Button=4,<br /> Title=5<br /><br /> }<br /> <br /> [DefaultProperty("Text"),<br /> ToolboxData("<{0}:TellaFriend runat=server></{0}:TellaFriend>"),<br /> Designer(typeof(ccc.TellaFriend.Design.TellaFriendDesing))]<br /> <br /> public class TellaFriend :System.Web.UI.WebControls.WebControl,INamingContainer<br /> {<br /><br /><br /> public Label lbl_title;<br /><br /> public TextBox txt_yourname;<br /> public TextBox txt_yourEmail;<br /> public TextBox txt_friendEmail;<br /> public TextBox txt_message;<br /><br /> public Button btn_send;<br /><br /> public RequiredFieldValidator req1;<br /> public RequiredFieldValidator req2;<br /> public RequiredFieldValidator req3;<br /> public RequiredFieldValidator req4;<br /><br /> public RegularExpressionValidator reg1;<br /> public RegularExpressionValidator reg2;<br /><br /> public ValidationSummary vs;<br /><br /> #region Tell a Friend Text<br /> <br /> [Bindable(true)]<br /> [Category("Appearance")]<br /> [DefaultValue("")]<br /> [Localizable(true)]<br /> <br /> public string Text<br /> {<br /> get<br /> {<br /> this.EnsureChildControls();<br /> string retVal = "";<br /><br /> switch (TellaFreindText)<br /> {<br /> case TellaFreindText.Your_Name:<br /> retVal = txt_yourname.Text;<br /> break;<br /><br /> case TellaFreindText.Your_Email:<br /> retVal = txt_yourEmail.Text;<br /> break;<br /><br /> case TellaFreindText.Friend_Email:<br /> retVal = txt_friendEmail.Text;<br /> break;<br /><br /> case TellaFreindText.Message:<br /> retVal = txt_message.Text;<br /> break;<br /> case TellaFreindText.Button:<br /> retVal = btn_send.Text;<br /> break;<br /> case TellaFreindText.Title:<br /> retVal = lbl_title.Text;<br /> break;<br /> }<br /><br /> return (retVal);<br /> }<br /><br /> set<br /> {<br /> this.EnsureChildControls();<br /> switch (TellaFreindText)<br /> {<br /> case TellaFreindText.Your_Name:<br /> txt_yourname.Text = value;<br /> break;<br /> case TellaFreindText.Your_Email:<br /> txt_yourEmail.Text = value;<br /> break;<br /> case TellaFreindText.Friend_Email:<br /> txt_friendEmail.Text = value;<br /> break;<br /> case TellaFreindText.Message:<br /> txt_message.Text = value;<br /> break;<br /> case TellaFreindText.Button:<br /> btn_send.Text = value;<br /> break;<br /> case TellaFreindText.Title:<br /> lbl_title.Text = value;<br /> break;<br /> }<br /> }<br /> }<br /><br /> #endregion<br /><br /> #region Tell a Freind CSS<br /> <br /> [Bindable(true)]<br /> [Category("Appearance")]<br /> [DefaultValue("")]<br /> [Localizable(true)]<br /> <br /> public string TellaFreindCss<br /> {<br /> get<br /> {<br /> this.EnsureChildControls();<br /> string retCss = "";<br /><br /> switch (TellaFreindText)<br /> {<br /> case TellaFreindText.Your_Name:<br /> retCss = txt_yourname.CssClass;<br /> break;<br /><br /> case TellaFreindText.Your_Email:<br /> retCss = txt_yourEmail.CssClass;<br /> break;<br /><br /> case TellaFreindText.Friend_Email:<br /> retCss = txt_friendEmail.CssClass;<br /> break;<br /><br /> case TellaFreindText.Message:<br /> retCss = txt_message.CssClass;<br /> break;<br /> case TellaFreindText.Button:<br /> retCss = btn_send.CssClass;<br /> break;<br /> case TellaFreindText.Title:<br /> retCss = lbl_title.CssClass;<br /> break;<br /> }<br /><br /> return (retCss);<br /> }<br /><br /> set<br /> {<br /> this.EnsureChildControls();<br /> switch (TellaFreindText)<br /> {<br /> case TellaFreindText.Your_Name:<br /> txt_yourname.CssClass = value;<br /> break;<br /> case TellaFreindText.Your_Email:<br /> txt_yourEmail.CssClass = value;<br /> break;<br /> case TellaFreindText.Friend_Email:<br /> txt_friendEmail.CssClass = value;<br /> break;<br /> case TellaFreindText.Message:<br /> txt_message.CssClass = value;<br /> break;<br /> case TellaFreindText.Button:<br /> btn_send.CssClass = value;<br /> break;<br /> case TellaFreindText.Title:<br /> lbl_title.CssClass = value;<br /> break;<br /> }<br /> }<br /> }<br /><br /> #endregion<br /><br /> #region Tell a Freind Width<br /> <br /> [Bindable(false), Category("Appearance"), DefaultValue(null),<br /> Description("The width of the button text in between the decorations for Text mode buttons. The full width of the button for Button mode buttons. Not used for Image mode buttons.")]<br /> <br /> public Unit TellafriendWidth<br /> {<br /> get<br /> {<br /> Unit retWidth = System.Web.UI.WebControls.Unit.Percentage(50);<br /><br /> switch (TellaFreindText)<br /> {<br /> case TellaFreindText.Your_Name:<br /> retWidth = txt_yourname.Width;<br /> break;<br /><br /> case TellaFreindText.Your_Email:<br /> retWidth = txt_yourEmail.Width;<br /> break;<br /><br /> case TellaFreindText.Friend_Email:<br /> retWidth = txt_friendEmail.Width;<br /> break;<br /><br /> case TellaFreindText.Message:<br /> retWidth = txt_message.Width;<br /> break;<br /> case TellaFreindText.Button:<br /> retWidth = btn_send.Width;<br /> break;<br /> case TellaFreindText.Title:<br /> retWidth = lbl_title.Width;<br /> break;<br /> }<br /><br /> return (retWidth);<br /> }<br /><br /> set<br /> {<br /> this.EnsureChildControls();<br /> switch (TellaFreindText)<br /> {<br /> case TellaFreindText.Your_Name:<br /> txt_yourname.Width = value;<br /> break;<br /> case TellaFreindText.Your_Email:<br /> txt_yourEmail.Width = value;<br /> break;<br /> case TellaFreindText.Friend_Email:<br /> txt_friendEmail.Width = value;<br /> break;<br /> case TellaFreindText.Message:<br /> txt_message.Width = value;<br /> break;<br /> case TellaFreindText.Title:<br /> lbl_title.Width = value;<br /> break;<br /> }<br /> }<br /> }<br /> #endregion<br /><br /> #region Tell a Freind Height<br /> <br /> [Bindable(false), Category("Appearance"), DefaultValue(null),<br /> Description("The width of the button text in between the decorations for Text mode buttons. The full width of the button for Button mode buttons. Not used for Image mode buttons.")]<br /> <br /> public Unit TellafriendHeight<br /> {<br /> get<br /> {<br /> Unit retHeight = System.Web.UI.WebControls.Unit.Percentage(50);<br /><br /> switch (TellaFreindText)<br /> {<br /> case TellaFreindText.Your_Name:<br /> retHeight = txt_yourname.Height;<br /> break;<br /><br /> case TellaFreindText.Your_Email:<br /> retHeight = txt_yourEmail.Height;<br /> break;<br /><br /> case TellaFreindText.Friend_Email:<br /> retHeight = txt_friendEmail.Height;<br /> break;<br /><br /> case TellaFreindText.Message:<br /> retHeight = txt_message.Height;<br /> break;<br /> case TellaFreindText.Button:<br /> retHeight = btn_send.Height;<br /> break;<br /> case TellaFreindText.Title:<br /> retHeight = lbl_title.Height;<br /> break;<br /> }<br /><br /> return (retHeight);<br /> }<br /><br /> set<br /> {<br /> this.EnsureChildControls();<br /> switch (TellaFreindText)<br /> {<br /> case TellaFreindText.Your_Name:<br /> txt_yourname.Height = value;<br /> break;<br /> case TellaFreindText.Your_Email:<br /> txt_yourEmail.Height = value;<br /> break;<br /> case TellaFreindText.Friend_Email:<br /> txt_friendEmail.Height = value;<br /> break;<br /> case TellaFreindText.Message:<br /> txt_message.Height = value;<br /> break;<br /> case TellaFreindText.Title:<br /> lbl_title.Height = value;<br /> break;<br /> }<br /> }<br /> }<br /> #endregion<br /><br /> #region Tell a FriendText<br /> <br /> [Bindable(false), Category("Appearance"),<br /> Description("")]<br /> <br /> public TellaFreindText TellaFreindText<br /> {<br /> get<br /> {<br /><br /> this.EnsureChildControls();<br /><br /> TellaFreindText retVal;<br /><br /> if (ViewState["textid"] == null)<br /> retVal = TellaFreindText.Your_Name;<br /> else<br /> retVal = (TellaFreindText)ViewState["textid"];<br /><br /> return (retVal);<br /><br /> }<br /><br /> set<br /> {<br /> ViewState["textid"] = value;<br /> this.EnsureChildControls();<br /> TellaFreindText retVal;<br /> retVal = value;<br /> <br /> <br /> }<br /> }<br /> #endregion<br /><br /> #region Bind<br /> <br /> protected override void CreateChildControls()<br /> {<br /><br /> req1 = new RequiredFieldValidator();<br /> req2 = new RequiredFieldValidator();<br /> req3 = new RequiredFieldValidator();<br /> req4 = new RequiredFieldValidator();<br /><br /> reg1 = new RegularExpressionValidator();<br /> reg2 = new RegularExpressionValidator();<br /><br /> vs = new ValidationSummary();<br /><br /> lbl_title = new Label();<br /><br /> txt_yourname = new TextBox();<br /> txt_yourEmail = new TextBox();<br /> txt_friendEmail = new TextBox();<br /> txt_message = new TextBox();<br /><br /> btn_send = new Button();<br /> btn_send.Click+=new EventHandler(btn_send_Click);<br /><br /> HtmlTable table = new HtmlTable();<br /> HtmlTableRow newRow;<br /> HtmlTableCell newCell;<br /><br /> table.Border = 0;<br /> table.Style.Add("DISPLAY", "inline");<br /> table.Style.Add("VERTICAL-ALIGN", "middle");<br /><br /> ///1st row<br /> newRow = new HtmlTableRow();<br /> newCell = new HtmlTableCell();<br /><br /> newCell.Controls.Add(lbl_title);<br /> newCell.ColSpan = 2;<br /> newRow.Cells.Add(newCell);<br /> table.Rows.Add(newRow);<br /><br /> ///2nd row<br /> newRow =new HtmlTableRow();<br /> newCell = new HtmlTableCell();<br /> newCell.Align = "right";<br /> newCell.InnerHtml = "<strong>Your Name:</strong>";<br /> newRow.Controls.Add(newCell);<br /><br /> newCell = new HtmlTableCell();<br /> txt_yourname.ID = "txtyourName";<br /> newCell.Controls.Add(txt_yourname);<br /><br /> req1.ControlToValidate = txt_yourname.ID;<br /> req1.ErrorMessage = "Enter Your Name";<br /> req1.SetFocusOnError = true;<br /> req1.Display = ValidatorDisplay.None;<br /> <br /> newCell.Controls.Add(req1);<br /><br /> newRow.Cells.Add(newCell);<br /> table.Rows.Add(newRow);<br /><br /> //3dr row<br /> newRow = new HtmlTableRow();<br /> newCell = new HtmlTableCell();<br /> newCell.Align = "right";<br /> newCell.InnerHtml = "<strong>Your Email:</strong>";<br /> newRow.Controls.Add(newCell);<br /><br /> newCell = new HtmlTableCell();<br /> txt_yourEmail.ID = "txtyourEmail";<br /> newCell.Controls.Add(txt_yourEmail);<br /><br /> req2.ControlToValidate = txt_yourEmail.ID;<br /> req2.ErrorMessage = "Enter Your Email Address";<br /> req2.SetFocusOnError = true;<br /> req2.Display = ValidatorDisplay.None;<br /> newCell.Controls.Add(req2);<br /><br /> reg1.ControlToValidate = txt_yourEmail.ID;<br /> reg1.ErrorMessage = "Invalid Email Address";<br /> reg1.ValidationExpression = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";<br /> reg1.SetFocusOnError = true;<br /> reg1.Display = ValidatorDisplay.None;<br /> newCell.Controls.Add(reg1);<br /><br /> newRow.Cells.Add(newCell);<br /> table.Rows.Add(newRow);<br /><br /> //4th row<br /> newRow = new HtmlTableRow();<br /> newCell = new HtmlTableCell();<br /> newCell.Align = "right";<br /> newCell.InnerHtml = "<strong>Friend's Email:</strong>";<br /> newRow.Controls.Add(newCell);<br /><br /> newCell = new HtmlTableCell();<br /> txt_friendEmail.ID = "txtFriendEmail";<br /> newCell.Controls.Add(txt_friendEmail);<br /><br /> req3.ControlToValidate = txt_friendEmail.ID;<br /> req3.ErrorMessage = "Enter Your Freind's Email Address";<br /> req3.SetFocusOnError = true;<br /> req3.Display = ValidatorDisplay.None;<br /> newCell.Controls.Add(req3);<br /><br /> reg2.ControlToValidate = txt_friendEmail.ID;<br /> reg2.ErrorMessage = "Invalid Email Address";<br /> reg2.ValidationExpression = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";<br /> reg2.SetFocusOnError = true;<br /> reg2.Display = ValidatorDisplay.None;<br /> newCell.Controls.Add(reg2);<br /><br /> newRow.Cells.Add(newCell);<br /> table.Rows.Add(newRow);<br /><br /> //5th row<br /> newRow = new HtmlTableRow();<br /> newCell = new HtmlTableCell();<br /> newCell.Align = "right";<br /> newCell.InnerHtml = "<strong>Message:</strong>";<br /> newRow.Controls.Add(newCell);<br /><br /> newCell = new HtmlTableCell();<br /> txt_message.TextMode = TextBoxMode.MultiLine;<br /> txt_message.ID = "txtMessage";<br /> newCell.Controls.Add(txt_message);<br /><br /> req4.ControlToValidate = txt_message.ID;<br /> req4.ErrorMessage = "Enter Message";<br /> req4.SetFocusOnError = true;<br /> req4.Display = ValidatorDisplay.None;<br /> newCell.Controls.Add(req4);<br /><br /> newRow.Cells.Add(newCell);<br /> table.Rows.Add(newRow);<br /><br /> //6th row<br /> newRow = new HtmlTableRow();<br /> newCell = new HtmlTableCell();<br /> newCell.Align = "right";<br /> newCell.InnerHtml = "";<br /> newRow.Controls.Add(newCell);<br /><br /> newCell = new HtmlTableCell();<br /> <br /> newCell.Controls.Add(btn_send);<br /><br /> vs.ShowMessageBox = true;<br /> vs.ShowSummary = false;<br /> newCell.Controls.Add(vs);<br /><br /> newRow.Cells.Add(newCell);<br /> table.Rows.Add(newRow);<br /><br /> table.CellPadding = 2;<br /> table.CellSpacing = 4;<br /> Controls.Add(table);<br /><br /> this.TellaFreindText = TellaFreindText.Button;<br /> this.Text = "Send Message";<br /> //this.Text = "Enter your name";<br /><br /> }<br /> #endregion<br /><br /> #region Button Event<br /> <br /> /// <br /> /// This delegate is called when the CoolButtonMode is set to Text.<br /> /// It's only job is to forward the event to any registered handelers that<br /> /// are encapsulating this control, including parent composite controls, or <br /> /// the page itself.<br /> /// <br /> ///<span> <</span>param name="sender">The sender of the event<span></</span>param><br /> /// <span><</span>param name="e">An EventArgs object.<span></</span>param><br /> <br /> public void btn_send_Click(object sender, EventArgs e)<br /> {<br /> <br /> System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();<br /> TellaFreindText = TellaFreindText.Your_Name;<br /> string subject = "Mail from" + this.Text;<br /> TellaFreindText = TellaFreindText.Your_Email;<br /> string from = this.Text;<br /> TellaFreindText = TellaFreindText.Friend_Email;<br /> string to = this.Text;<br /> TellaFreindText = TellaFreindText.Message;<br /> string body = this.Text;<br /><br /> System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage(from, to, subject, body);<br /> System.Net.Mail.SmtpClient cl = new System.Net.Mail.SmtpClient("localhost");<br /> mm.IsBodyHtml = true;<br /> cl.Send(mm);<br /><br /> }<br /> #endregion<br /> }<br />}<br /><br />namespace ccc.TellaFriend.Design<br />{<br /> public class TellaFriendDesing :ControlDesigner<br /> {<br /> /// <br /> /// Returns a design view of the control as rendered by the control itself.<br /> ///<br /> /// The HTML of the design time control.<br /> /// <br /> <br /> #region Bind control at desing time<br /> <br /> public override string GetDesignTimeHtml()<br /> {<br /> <br /> <br /> TellaFriend tf = (TellaFriend)Component;<br /> <br /> // If there are no controls, then it's the first time through the <br /> // designer, so set the text to the unique id. This will also <br /> // cause EnsureChildControls() to be called in Text(), which will<br /> // build out the rest of the control.<br /> if (tf.Controls.Count == 0)<br /> tf.Text = tf.UniqueID;<br /><br /> StringWriter sw = new StringWriter();<br /> HtmlTextWriter tw = new HtmlTextWriter(sw);<br /><br /> tf.RenderBeginTag(tw);<br /> tf.RenderControl(tw);<br /> tf.RenderEndTag(tw);<br /><br /> return (sw.ToString());<br /> }<br /> #endregion<br /> }<br />}Imrankhan Pathanhttp://www.blogger.com/profile/00481180443247674321noreply@blogger.com0tag:blogger.com,1999:blog-5077567527447631069.post-29309800116761925952007-11-02T02:52:00.000-07:002008-06-20T04:36:42.037-07:00Watermark Imageusing System;<br />using System.IO;<br />using System.Drawing;<br />using System.Drawing.Image;<br /><br />public void AddWatermark(string filename, string watermarkText, Stream outputStream) {<br /> Bitmap bitmap = Bitmap.FromFile(filename);<br /> Font font = new Font("Arial", 20, FontStyle.Bold, GraphicsUnit.Pixel);<br /> Color color = Color.FromArgb(10, 0, 0, 0); //Adds a black watermark with a low alpha value (almost transparent).<br /> Point atPoint = new Point(100, 100); //The pixel point to draw the watermark at (this example puts it at 100, 100 (x, y)).<br /> SolidBrush brush = new SolidBrush(color);<br /><br /> Graphics graphics = null;<br /> try {<br /> graphics = Graphics.FromImage(bitmap);<br /> } catch {<br /> Bitmap temp = bitmap;<br /> bitmap = new Bitmap(bitmap.Width, bitmap.Height);<br /> graphics = Graphics.FromImage(bitmap);<br /> graphics.DrawImage(temp, new Rectangle(0, 0, bitmap.Width, bitmap.Height), 0, 0, bitmap.Width, bitmap.Height, GraphicsUnit.Pixel);<br /> temp.Dispose();<br /> }<br /><br /> graphics.DrawString(text, font, brush, atPoint);<br /> graphics.Dispose();<br /><br /> bitmap.Save(outputStream);<br />}<br /><br />To call it, just add something like this to your aspx file (assume the class is called MyImage):<br /><br />string filename = Request.MapPath(Request.QueryString["filename"]);<br />MyImage image = new MyImage();<br />image.AddWatermark(filename, "Watermark Test", HttpResponse.OutputStream);Imrankhan Pathanhttp://www.blogger.com/profile/00481180443247674321noreply@blogger.com0tag:blogger.com,1999:blog-5077567527447631069.post-26912898351457119492007-08-24T23:55:00.000-07:002007-08-25T01:22:14.386-07:00Themes<span style="color: rgb(102, 0, 0);">ASP.NET Themes<br /></span><h2 style="color: rgb(102, 0, 0); font-weight: normal;"><span style="font-size:85%;">What are ASP.NET 2.0 Themes?</span></h2><br />One of the most important aspects of a Web application is a consistent look and feel across the site. ASP.NET 1.x developers usually use Cascading Style Sheets (CSS) to implement a consistent look and feel. ASP.NET 2.0 themes significantly improve upon CSS because they give the ASP.NET developer the ability to define the appearance of ASP.NET server controls as well as HTML elements. ASP.NET themes can be applied to individual controls, a specific Web page, or an entire Web application. Themes use a combination of CSS files, an optional skin file, and an optional Images directory if images are needed. The skin file controls the visual appearance of ASP.NET server controls.<br /><br /><h2 style="color: rgb(102, 0, 0); font-weight: normal;"><span style="font-size:100%;">Where are Themes Stored?</span></h2><br /><p>The location where themes are stored differs based upon their scope. Themes that can be applied to any application are stored in the following folder:</p> <p style="color: rgb(102, 0, 0);"><code class="padded">C:\WINDOWS\Microsoft.NET\Framework\v2.x.xxxxx\ASP.NETClientFiles\Themes\<theme_name></theme_name></code></p> <p>A theme that is specific to a particular application is stored in an App_Themes\<theme_name> directory in the root of the Web site.</theme_name></p> <p><strong class="action">Note: </strong>A skin file should only modify server control properties that affect appearance. </p> <p>A global theme is a theme that can be applied to any application or Web site running on the Web server. These themes are stored by default in the ASP.NETClientfiles\Themes directory that is inside of the v2.x.xxxxx directory. Alternatively, you can move the theme files into the aspnet_client/system_web/[version]/Themes/[theme_name] folder in the root of your Web site.</p> <p>Application-specific themes can only be applied to the application in which the files reside. These files are stored in the App_Themes/<theme_name> directory in the root of the Web site.</theme_name></p> <h2 style="color: rgb(102, 0, 0); font-weight: normal;"><span style="font-size:85%;">The Components of a Theme</span></h2> <p>A theme is made up of one or more CSS files, an optional skin file, and an optional Images folder. The CSS files can be any name you wish (i.e. default.css or theme.css, etc.) and must be in the root of the themes folder. The CSS files are used to define ordinary CSS classes and attributes for specific selectors. To apply one of the CSS classes to a page element, the <strong class="action">CSSClass</strong> property is used.</p> <p>The skin file is an XML file that contains property definitions for ASP.NET server controls. The code listed below is an example skin file.</p><br /><pre style="color: rgb(51, 51, 153);"><asp:TextBox runat="server"<br />BackColor="#FFC080"<br />BorderColor="Black"<br />BorderStyle="Solid"<br />BorderWidth="1px"<br />Font-Names="Tahoma, Verdana, Arial"<br />Font-Size="Smaller" /><br /><br /><asp:Button runat="server"<br />BackColor="#C04000"<br />BorderColor="Maroon"<br />BorderStyle="Solid"<br />BorderWidth="2px"<br />Font-Names="Tahoma,Verdana,Arial"<br />Font-Size="Smaller"<br />ForeColor="#FFFFC0" /></pre><br /><p><strong class="action">Figure 1</strong> below shows a small ASP.NET page browsed without a theme applied. <strong class="action">Figure 2</strong> shows the same file with a theme applied. The background color and text color are configured via a CSS file. The appearance of the button and textbox are configured using the skin file listed above.</p><br /><p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://static.asp.net/asp.net/images/pss/module10_01.gif"><img style="cursor: pointer; width: 320px;" src="http://static.asp.net/asp.net/images/pss/module10_01.gif" alt="" border="0" /></a></p><p><strong>Figure 1</strong>: No Theme</p><p><br /></p><br /><pre style="color: rgb(51, 0, 153);" id="line1"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://static.asp.net/asp.net/images/pss/module10_02.gif"><img style="cursor: pointer; width: 320px;" src="http://static.asp.net/asp.net/images/pss/module10_02.gif" alt="" border="0" /></a><br /></pre><p class="caption"><strong>Figure 2</strong>: Theme Applied</p> <p>The skin file listed above defines a default skin for all TextBox controls and Button controls. That means that every TextBox control and Button control inserted on a page will take on this appearance. You can also define a skin that can be applied to specific instances of these controls using the <strong class="action">SkinID</strong> property of the control.</p> <p>The code below defines a skin for a Button control. Only Button controls with a <strong class="action">SkinID</strong> property of <strong class="action">goButton</strong> will take on the appearance of the skin.</p><br /><pre style="color: rgb(51, 51, 153);"><asp:Button runat="server"<br />BackColor="#C04000"<br />BorderColor="Maroon"<br />BorderStyle="Solid"<br />BorderWidth="2px"<br />Font-Names="Tahoma,Verdana,Arial"<br />Font-Size="Smaller"<br />ForeColor="#FFFFC0"<br />Text=go<br />SkinID=goButton<br />Width="95px" /></pre><br /><br />You can only have one default skin per server control type. If you require additional skins, you should use the SkinID property.<br /><br /><span style="font-size:85%;"><span style="color: rgb(102, 0, 0);">Applying Themes to Pages</span></span><br /><br />A theme can be applied using any one of the following methods:<br /><br />* In the <pages> element of the web.config file<br />* In the @Page directive of a page<br />* Programmatically<br /><span style="color: rgb(102, 0, 0);font-size:85%;" ><br /><span>Applying a Theme in the Configuration File</span></span><br /><br />To apply a theme in the applications configuration file, use the following syntax:<br /></pages><pre style="color: rgb(51, 51, 153);"><system.web><br /><pages theme="CoolTheme" /><br />...<br /></system.web></pre><br /><br /><p>The theme name specified here must match the name of the themes folder. This folder can exist either in any one of the locations mentioned earlier in this course. If you attempt to apply a theme that doesn't exist, a configuration error will occur.</p> <h2 style="color: rgb(102, 0, 0); font-weight: normal;"><span style="font-size:85%;">Applying a Theme in the Page Directive</span></h2> <p>You can also apply a theme in the @ Page directive. This method allows you to use a theme for a specific page.</p> <p>To apply a theme in the @Page directive, use the following syntax:</p><br /><pre style="color: rgb(51, 51, 153);"><%@ Page Language="C#" Theme=CoolTheme CodeFile="Default.aspx.cs" ... %></pre><br /><br /><p>Once again, the theme specified here must match the theme folder as mentioned previously. If you attempt to apply a theme that doesn't exist, a build failure will occur. Visual Studio will also highlight the attribute and notify you that no such theme exists.</p> <h2 style="font-weight: normal; color: rgb(102, 0, 0);"><span style="font-size:85%;">Applying a Theme Programmatically</span></h2> <p>To apply a theme programmatically, you must specify the <strong class="action">Theme</strong> property for the page in the <strong class="action">Page_PreInit</strong> method.</p> <p>To apply a theme programmatically, use the following syntax:</p> <span style="color: rgb(51, 51, 153);">Page.Theme = CoolTheme;<br /></span><p>It is necessary to apply the theme in the PreInit method due to the page lifecycle. If you apply it after that point, the pages theme will have already been applied by the runtime and a change at that point is too late in the lifecycle. If you apply a theme that doesn't exist, an <strong class="action">HttpException</strong> occurs. When a theme is applied programmatically, a build warning will occur if any server controls have a SkinID property specified. This warning is intended to inform you that no theme is declaratively applied and it can be ignored.</p> <h1 style="color: rgb(102, 0, 0); font-weight: normal;"><span style="font-size:85%;">Exercise 1 : Applying a Theme</span></h1> <p>In this exercise, you will apply an ASP.NET theme to a Web site.</p> <p class="blockquote"><strong class="action"><span style="font-size:85%;">IMPORTANT</span>: </strong>If you are using Microsoft Word to enter information into a skin file, make sure that you are not replacing regular quotes with smart quotes. Smart quotes will cause problems with skin files.</p> <ol><li>Create a new ASP.NET Web site.</li><li>Right-click on the project in Solution Explorer and choose Add New Item.</li><li>Choose Web Configuration File from the list of files and click Add.</li><li>Right-click on the project in Solution Explorer and choose Add New Item.</li><li>Choose Skin File and click Add.</li><li>Click Yes when asked if youd like to place the file inside of the App_Themes folder.</li><li>Right-click on the SkinFile folder inside of the App_Themes folder in Solution Explorer and choose Add New Item.</li><li>Choose Style Sheet from the list of files and click Add. You now have all of the files necessary to implement your new theme. However, Visual Studio has named your themes folder SkinFile. Right-click on that folder and change the name to CoolTheme.</li><li>Open the SkinFile.skin file and add the following code the end of the file:</li></ol><br /><br /><pre style="color: rgb(51, 51, 153);" class="blockquote"><asp:TextBox runat="server"<br />BackColor="#FFC080"<br />BorderColor="Black"<br />BorderStyle="Solid"<br />BorderWidth="1px"<br />Font-Names="Tahoma, Verdana, Arial"<br />Font-Size="Smaller"<br />/><br /><br /><asp:Button runat="server"<br />BackColor="#C04000"<br />BorderColor="Maroon"<br />BorderStyle="Solid"<br />BorderWidth="2px"<br />Font-Names="Tahoma,Verdana,Arial"<br />Font-Size="Smaller"<br />ForeColor="#FFFFC0"<br />/><br /><br /><asp:Button runat="server"<br />BackColor="#C04000"<br />BorderColor="Maroon"<br />BorderStyle="Solid"<br />BorderWidth="2px"<br />Font-Names="Tahoma,Verdana,Arial"<br />Font-Size="Smaller"<br />ForeColor="#FFFFC0"<br />Text="go"<br />SkinID="goButton"<br />Width="95px"<br />/></pre><br /><br /><br />10. Save the SkinFile.skin file.<br />11. Open the StyleSheet.css.<br />12. Replace all of the text in it with the following:<br /><br /><span style="color: rgb(51, 51, 153);">body {</span><br /><span style="color: rgb(51, 51, 153);"> background-color: #FFDEAD;</span><br /><span style="color: rgb(51, 51, 153);">}<br /><br /></span><ol start="13"><li>Save the StyleSheet.css file.</li><li>Open the Default.aspx page.</li><li>Add a TextBox control and a Button control.</li><li>Save the page. Now browse the Default.aspx page. It should display as a normal Web form.</li><li>Open the web.config file.</li><li>Add the following directly underneath the opening <pre style="color: rgb(51, 51, 153);" class="blockquote"><system.web></pre> tag:</li></ol><br /><pre class="blockquote"><pages theme="CoolTheme" /></pre><br />19. Save the web.config file. Now browse the Default.aspx page. It should display with the theme applied.<br />20. If it's not already open, open the Default.aspx page in Visual Studio.<br />21. Select the Button.<br />22. Change the SkinID property to goButton. Notice that Visual Studio provides a dropdown with valid SkinID values for a Button control.<br />23. Save the page. Now preview the page in your browser again. The Button should now say "go" and should be wider in appearance.<br /><br />Using the SkinID property, you can easily configure different skins for different instances of a particular type of server control.<br /><span style="font-weight: bold; color: rgb(102, 0, 0);font-size:85%;" ><br /></span><span style="color: rgb(102, 0, 0);font-size:85%;" >The StyleSheetTheme Property</span><br /><br />So far, we've talked only about applying themes using the Theme property. When using the Theme property, the skin file will override any declarative settings for server controls. For example, in exercise 1, you specified a SkinID of "goButton" for the Button control and that changed the Button's text to "go". You may have noticed that the Text property of the Button in the designer was set to "Button", but the theme overrode that. The theme will always override any property settings in the designer.<br /><br />If you'd like to be able to override the properties defined in the theme's skin file with properties specified in the designer, you can use the StyleSheetTheme property instead of the Theme property. The StyleSheetTheme property is the same as the Theme property except that it does not override all explicit property settings like the Theme property does.<br /><br />To see this in action, open the web.config file from the project in exercise 1 and change the <pages> element to the following:<br /><br /></pages><pre style="color: rgb(51, 51, 153);"><pages styleSheetTheme="CoolTheme" /></pre><br /><br />Now browse the Default.aspx page and you'll see that the Button control has a Text property of "Button" again. That's because the explicit property setting in the designer is overriding the Text property set by the goButton SkinID.<br />Overriding Themes<br /><br />A global theme can be overridden by applying a theme by the same name in the App_Themes folder of the application. However, the theme is not applied in a true override scenario. If the runtime encounters theme files in the App_Themes folder, it will apply the theme using those files and will ignore the global theme.<br /><br />The StyleSheetTheme property is overridable and can be overridden in code as follows:<br /><br /><span style="color: rgb(51, 51, 153);">const String THEME_NAME = "CoolTheme";</span><br /><span style="color: rgb(51, 51, 153);">public override string StyleSheetTheme {</span><br /><span style="color: rgb(51, 51, 153);"> get { return THEME_NAME; }</span><br /><span style="color: rgb(51, 51, 153);"> set { Page.StyleSheetTheme = THEME_NAME; }</span><br /><span style="color: rgb(51, 51, 153);">}</span>Imrankhan Pathanhttp://www.blogger.com/profile/00481180443247674321noreply@blogger.com0tag:blogger.com,1999:blog-5077567527447631069.post-19759205717926383782007-08-24T21:14:00.000-07:002007-08-24T23:49:57.008-07:00Profiles<span style="font-size:100%;">ASP.NET 2.0 represents a substantial improvement in the area of personalized Web sites. In addition to the membership features weve already covered, ASP.NET profiles, themes, and Web parts significantly enhance personalization in Web sites.<br /><br /></span><h2 style="color: rgb(102, 0, 0); font-weight: normal;"><span style="font-size:100%;">ASP.NET Profiles</span></h2><br /><span style="font-size:100%;">ASP.NET profiles are similar to sessions. The difference is that a profile is persistent whereas a session is lost when the browser is closed. Another big difference between sessions and profiles is that profiles are strongly typed, therefore providing you with IntelliSense during the development process.</span> <p><span style="font-size:100%;">A profile is defined in either the machines configuration file or the web.config file for the application. (You cannot define a profile in a sub-folders web.config file.) The code below defines a profile to store the Web site visitors first and last name.</span></p><pre style="color: rgb(51, 0, 153);"><profile><br /><properties><br /><add name="FirstName" /><br /><br /><add name="LastName" /><br /></properties><br /></profile></pre>The default data type for a profile property is System.String. In the above example, no data type was specified. Therefore the FirstName and LastName properties are both of type String. As previously mentioned, profile properties are strongly typed. The code below adds a new property for age that is of type Int32.<br /><br /><pre style="color: rgb(51, 0, 153);"><profile><br /><properties><br /><br /><add name="FirstName" /><br /><add name="LastName" /><br /><add name="Age" type="Int32"/><br /></properties><br /><br /></profile></pre><br />Profiles are generally used with ASP.NET Forms authentication. When used in combination with Forms authentication, each user has a separate profile associated with their user ID. However, it is also possible to allow the use of profiles in an anonymous application using the <anonymousidentification> element in the configuration file along with the <strong class="action">allowAnonymous</strong> attribute as shown below:<br /><br /></anonymousidentification><pre style="color: rgb(51, 0, 153);"><anonymousIdentification enabled="true" /><br /><br /><profile><br /><properties><br /><add name="FirstName" allowAnonymous="true" /><br /><add name="LastName" allowAnonymous="true" /><br /></properties><br /></profile></pre><br /><br />When an anonymous user browses the site, ASP.NET creates an instance of <strong class="action">ProfileCommon</strong> for the user. This profile uses a unique ID stored in a cookie on the browser to identify the user as a unique visitor. In this way, you can store profile information for users who are browsing anonymously.<br /><br /><h2 style="color: rgb(102, 0, 0); font-weight: normal;"><span style="font-size:100%;">Profile Groups</span></h2><br /><p>It is possible to group properties of profiles. By grouping properties, it is possible to simulate multiple profiles for a specific application.</p> <p>The following configuration configures a FirstName and LastName property for two groups; Buyers and Prospects.</p><br /><br /><pre style="color: rgb(51, 0, 153);"><profile><br /><br /><properties><br /><group name="Buyers"><br /> <add name="FirstName" /><br /> <add name="Lastname" /><br /> <add name="NumberOfPurchases" type="Int32" /><br /><br /></group><br /><group name="Prospects"><br /> <add name="FirstName" /><br /> <add name="Lastname" /><br /></group><br /></properties><br /><br /></profile></pre><br /><br />It is then possible to set properties on a particular group as follows:<br /><br /><pre style="color: rgb(51, 0, 153); font-weight: bold;"><span style="font-weight: normal;">Profile.Buyers.NumberOfPurchases += 1;</span><br /><br /></pre><h2 style="color: rgb(102, 0, 0); font-weight: normal;"><span style="font-size:100%;">Storing Complex Objects</span></h2>So far, the examples we've covered have stored simple data types in a profile. It is also possible to store complex data types in a profile by specifying the method of serialization using the <strong class="action">serializeAs</strong> attribute as follows:<br /><br /><pre style="color: rgb(51, 0, 153);"><add name="PurchaseInvoice"<br />type="PurchaseInvoice"<br />serializeAs="Binary"<br />/></pre><br /><br />In this case, the type is PurchaseInvoice. The PurchaseInvoice class needs to be marked as serializable and can contain any number of properties. For example, if PurchaseInvoice has a property called <strong class="action">NumItemsPurchased</strong>, you can refer to that property in code as follows:<br /><br /><pre style="color: rgb(51, 0, 153); font-weight: bold;"><span style="font-weight: normal;">Profile.PurchaseInvoice.NumItemsPurchased</span><br /><br /></pre><h2 style="color: rgb(102, 0, 0); font-weight: normal;"><span style="font-size:100%;">Profile Inheritance</span></h2><br />It is possible to create a profile for use in multiple applications. By creating a profile class that derives from ProfileBase, you can reuse a profile in several applications by using the <strong class="action">inherits</strong> attribute as shown below:<br /><br /><pre style="color: rgb(51, 0, 153);"><profile inherits="PurchasingProfile" /></pre><br /><br />In this case, the class <strong class="action">PurchasingProfile</strong> would look<br />like so:<br /><pre style="font-weight: bold; color: rgb(51, 0, 153);"><span style="font-weight: normal;">using System;</span><br /><span style="font-weight: normal;">using System.Web.Profile;</span><br /><span style="font-weight: normal;">public class PurchasingProfile : ProfileBase {</span><br /><span style="font-weight: normal;">private string _ProductName;</span><br /><span style="font-weight: normal;">private Int32 _ProductID;</span><br /><span style="font-weight: normal;">public string ProductName {</span><br /><span style="font-weight: normal;">get { return _ProductName; }</span><br /><span style="font-weight: normal;">set { _ProductName = value; }</span><br /><span style="font-weight: normal;">}</span><br /><span style="font-weight: normal;">public Int32 ProductID {</span><br /><span style="font-weight: normal;">get { return _ProductID; }</span><br /><span style="font-weight: normal;">set { _ProductID = value; }</span><br /><span style="font-weight: normal;">}</span><br /><span style="font-weight: normal;">}</span><br /><br /><br /></pre><br /><h2 style="color: rgb(102, 0, 0); font-weight: normal;"><span style="font-size:100%;">Profile Providers</span></h2> <p>ASP.NET profiles use the provider model. The default provider stores the information in a SQL Server Express database in the App_Data folder of the Web application using the SqlProfileProvider provider. If the database doesn't exist, ASP.NET will automatically create it when the profile attempts to store information.</p> <p>In some cases, however, you may want to develop your own profile provider. The ASP.NET profile feature enables you to easily use different providers.</p> <p>You create a custom profile provider when:</p> <ul><li>You need to store profile information in a data source, such as in a FoxPro database or in an Oracle database, that is not supported by the profile providers included with the .NET Framework.</li><li>You need to manage profile information using a database schema that is different from the database schema used by the providers included with the .NET Framework. A common example is that you want to integrate profile information with user data in an existing SQL Server database.</li></ul> <h3 style="color: rgb(102, 0, 0); font-weight: normal;"><span style="font-size:100%;">Required Classes</span></h3> <p>To implement a profile provider, you create a class that inherits the System.Web.Profile.ProfileProvider abstract class. The <strong class="action">ProfileProvider</strong> abstract class in turn inherits the System.Configuration.SettingsProvider abstract class, which inherits the System.Configuration.Provider.ProviderBase abstract class. Because of this inheritance chain, in addition to the required members of the <strong class="action">ProfileProvider</strong> class, you must implement the required members of the <strong class="action">SettingsProvider</strong> and <strong class="action">ProviderBase</strong> classes.</p> <p>The following tables describe the properties and methods that you must implement from the <strong class="action">ProviderBase</strong>, <strong class="action">SettingsProvider</strong>, and <strong class="action">ProfileProvider</strong> abstract classes.</p> <h3 style="color: rgb(102, 0, 0); font-weight: normal;">ProviderBase Members</h3><br /><table class="gridlines" cellpadding="0" cellspacing="1"><tbody><tr><td><strong>Member</strong></td><td><strong>Description</strong></td></tr><tr><td>Initialize method</td><br /><td>Takes as input the name of the provider instance and a<br />NameValueCollection of configuration settings. Used to set options and<br />property values for the provider instance, including implementation-specific<br />values and options specified in the machine configuration or Web.config file.</td><br /></tr><br /></tbody></table><br /><span style="font-size:100%;"><br /></span><h3 style="color: rgb(102, 0, 0); font-weight: normal;"><span style="font-size:100%;">SettingsProvider Members</span></h3><br /><table style="width: 679px;" class="gridlines" cellpadding="0" cellspacing="1"><br /><tbody><tr><br /><td><strong>Member</strong></td><br /><td><strong>Description</strong></td><br /></tr><br /><tr><br /><td>ApplicationName property</td><br /><td>The application name that is stored with each profile. The<br />profile provider uses the application name to store profile information<br />separately for each application. This enables multiple ASP.NET applications<br />to use the same data source without a conflict if the same user name is<br />created in different applications. Alternatively, multiple ASP.NET<br />applications can share a profile data source by specifying the same<br />application name.</td><br /></tr><br /><tr><br /><td>GetPropertyValues method</td><br /><td>Takes as input a SettingsContext and a<br />SettingsPropertyCollection object.<br /><br />The <strong class="action">SettingsContext</strong> provides information about the<br />user. You can use the information as a primary key to retrieve profile<br />property information for the user. Use the <strong class="action">SettingsContext</strong> object to<br />get the user name and whether the user is authenticated or anonymous.<br /><br />The <strong class="action">SettingsPropertyCollection</strong> contains a<br />collection of SettingsProperty objects. Each <strong class="action">SettingsProperty</strong> object<br />provides the name and type of the property as well as additional information<br />such as the default value for the property and whether the property is<br />read-only. The <strong class="action">GetPropertyValues</strong> method populates a<br />SettingsPropertyValueCollection with SettingsPropertyValue objects based on<br />the <strong class="action">SettingsProperty</strong> objects provided as input. The values from the<br />data source for the specified user are assigned to the PropertyValue<br />properties for each <strong class="action">SettingsPropertyValue</strong> object and the entire<br />collection is returned.<br /><br />Calling the method also updates the LastActivityDate value<br />for the specified user profile to the current date and time.</td><br /></tr><br /><tr><br /><td>SetPropertyValues method</td><br /><td>Takes as input a <strong class="action">SettingsContext</strong> and a<br /><strong class="action">SettingsPropertyValueCollection</strong> object.<br /><br />The <strong class="action">SettingsContext</strong> provides information about the<br />user. You can use the information as a primary key to retrieve profile<br />property information for the user. Use the <strong class="action">SettingsContext</strong> object to<br />get the user name and whether the user is authenticated or anonymous.<br />The <strong class="action">SettingsPropertyValueCollection</strong> contains a<br />collection of <strong class="action">SettingsPropertyValue</strong> objects.<br />Each <strong class="action">SettingsPropertyValue</strong><br />object provides the name, type, and value of the property as well as<br />additional information such as the default value for the property and whether<br />the property is read-only. The <strong class="action">SetPropertyValues</strong> method updates the<br />profile property values in the data source for the specified user.<br /><br />Calling the method also updates the <strong class="action">LastActivityDate</strong><br />and LastUpdatedDate values for the specified user profile to the current date<br />and time.</td><br /></tr><br /></tbody></table><br /><span style="color: rgb(102, 0, 0);font-size:100%;" ><br /></span><h3 style="color: rgb(102, 0, 0); font-weight: normal;"><span style="font-size:100%;">ProfileProvider Members</span></h3><br /><table class="gridlines" cellpadding="0" cellspacing="1"><br /><tbody><tr><br /><td><strong>Member</strong></td><br /><td><strong>Description</strong></td><br /></tr><br /><tr><br /><td>DeleteProfiles method</td><br /><td>Takes as input a string array of user names and deletes<br />from the data source all profile information and property values for the<br />specified names where the application name matches the <strong class="action">ApplicationName</strong><br /><br />property value.<br />If your data source supports transactions, it is<br />recommended that you include all delete operations in a transaction and that<br />you roll back the transaction and throw an exception if any delete operation<br />fails.</td><br /></tr><br /><tr><br /><td>DeleteProfiles method</td><br /><td>Takes as input a collection of ProfileInfo objects and<br />deletes from the data source all profile information and property values for<br />each profile where the application name matches the<br /><strong class="action">ApplicationName</strong> property value.<br />If your data source supports transactions, it is<br />recommended that you include all delete operations in a transaction and roll<br />back the transaction and throw an exception if any delete operation fails.</td><br /></tr><br /><tr><br /><td>DeleteInactiveProfiles method</td><br /><td>Takes as input a ProfileAuthenticationOption value and a<br />DateTime object and deletes from the data source all profile information and<br />property values where the last activity date is less than or equal to the<br />specified date and time and where the application name matches the<br /><strong class="action">ApplicationName</strong> property value.<br />The <strong class="action">ProfileAuthenticationOption</strong> parameter specifies<br />whether only anonymous profiles, only authenticated profiles, or all profiles<br />are to be deleted.<br /><br />If your data source supports transactions, it is<br />recommended that you include all delete operations in a transaction and roll<br />back the transaction and throw an exception if any delete operation fails.</td><br /></tr><br /><tr><br /><td>GetAllProfiles method</td><br /><td>Takes as input a <strong class="action">ProfileAuthenticationOption</strong> value,<br />an integer that specifies the page index, an integer that specifies the page<br />size, and a reference to an integer that will be set to the total count of<br />profiles. Returns a ProfileInfoCollection that contains <strong class="action">ProfileInfo</strong><br />objects for all profiles in the data source where the application name<br />matches the <strong class="action">ApplicationName</strong> property value. The<br /><strong class="action">ProfileAuthenticationOption</strong><br /><br />parameter specifies whether only anonymous profiles, only authenticated<br />profiles, or all profiles are to be returned.<br /><br />The results returned by the <strong class="action">GetAllProfiles</strong> method<br />are constrained by the page index and page size values. The page size value<br />specifies the maximum number of <strong class="action">ProfileInfo</strong> objects to<br />return in the <strong class="action">ProfileInfoCollection</strong>.<br />The page index value specifies which page of results to return, where 1<br />identifies the first page. The parameter for total records is an out<br />parameter (you can use <strong class="action">ByRef</strong> in Visual Basic) that is set to the total<br />number of profiles. For example, if the data store contains 13 profiles for<br />the application and the page index value is 2 with a page size of 5, the<br /><strong class="action">ProfileInfoCollection</strong><br /><br />returned contains the sixth through the tenth profiles. The total records<br />value is set to 13 when the method returns.</td><br /></tr><br /><tr><br /><td>GetAllInactiveProfiles method</td><br /><td>Takes as input a <strong class="action">ProfileAuthenticationOption</strong> value,<br />a <strong class="action">DateTime</strong> object, an integer that specifies the page index, an<br />integer that specifies the page size, and a reference to an integer that will<br />be set to the total count of profiles. Returns a <strong class="action">ProfileInfoCollection</strong><br /><br />that contains <strong class="action">ProfileInfo</strong> objects for all profiles in the data source<br />where the last activity date is less than or equal to the specified <strong class="action">DateTime</strong><br />and where the application name matches the <strong class="action">ApplicationName</strong> property<br />value. The <strong class="action">ProfileAuthenticationOption</strong> parameter specifies whether<br />only anonymous profiles, only authenticated profiles, or all profiles are to<br />be returned.<br /><br />The results returned by the <strong class="action">GetAllInactiveProfiles</strong><br /><br />method are constrained by the page index and page size values. The page size<br />value specifies the maximum number of <strong class="action">ProfileInfo</strong> objects to return in<br />the <strong class="action">ProfileInfoCollection</strong>. The page index value specifies which page<br />of results to return, where 1 identifies the first page. The parameter for<br />total records is an out parameter (you can use <strong class="action">ByRef</strong> in Visual Basic)<br />that is set to the total number of profiles. For example, if the data store<br />contains 13 profiles for the application and the page index value is 2 with a<br />page size of 5, the <strong class="action">ProfileInfoCollection</strong> returned contains the sixth<br />through the tenth profiles. The total records value is set to 13 when the<br />method returns.</td><br /></tr><br /><tr><br /><td>FindProfilesByUserName method</td><br /><td>Takes as input a <strong class="action">ProfileAuthenticationOption</strong> value,<br />a string containing a user name, an integer that specifies the page index, an<br />integer that specifies the page size, and a reference to an integer that will<br />be set to the total count of profiles. Returns a <strong class="action">ProfileInfoCollection</strong><br />that contains <strong class="action">ProfileInfo</strong> objects for all profiles in the data source<br />where the user name matches the specified user name and where the application<br />name matches the <strong class="action">ApplicationName</strong> property value.<br />The <strong class="action">ProfileAuthenticationOption</strong><br /><br />parameter specifies whether only anonymous profiles, only authenticated<br />profiles, or all profiles are to be returned.<br /><br />If your data source supports additional search<br />capabilities, such as wildcard characters, you can provide more extensive<br />search capabilities for user names.<br /><br />The results returned by the <strong class="action">FindProfilesByUserName</strong><br />method are constrained by the page index and page size values. The page size<br />value specifies the maximum number of <strong class="action">ProfileInfo</strong> objects to return in<br />the <strong class="action">ProfileInfoCollection</strong>. The page index value specifies which page<br />of results to return, where 1 identifies the first page. The parameter for<br />total records is an out parameter (you can use <strong class="action">ByRef</strong> in Visual Basic)<br />that is set to the total number of profiles. For example, if the data store<br />contains 13 profiles for the application and the page index value is 2 with a<br />page size of 5, the <strong class="action">ProfileInfoCollection</strong> returned contains the sixth<br />through the tenth profiles. The total records value is set to 13 when the<br />method returns.</td><br /><br /></tr><br /><tr><br /><td>FindInactiveProfilesByUserName method</td><br /><td>Takes as input a <strong class="action">ProfileAuthenticationOption</strong> value,<br />a string containing a user name, a <strong class="action">DateTime</strong> object, an integer that<br />specifies the page index, an integer that specifies the page size, and a<br />reference to an integer that will be set to the total count of profiles.<br />Returns a <strong class="action">ProfileInfoCollection</strong> that contains<br /><strong class="action">ProfileInfo</strong><br /><br />objects for all profiles in the data source where the user name matches the<br />specified user name, where the last activity date is less than or equal to<br />the specified <strong class="action">DateTime</strong>, and where the application name<br />matches the <strong class="action">ApplicationName</strong><br />property value. The <strong class="action">ProfileAuthenticationOption</strong> parameter specifies<br />whether only anonymous profiles, only authenticated profiles, or all profiles<br />are to be returned.<br /><br />If your data source supports additional search<br />capabilities, such as wildcard characters, you can provide more extensive<br />search capabilities for user names.<br /><br />The results returned by the <strong class="action">FindInactiveProfilesByUserName</strong><br /><br />method are constrained by the page index and page size values. The page size<br />value specifies the maximum number of <strong class="action">ProfileInfo</strong> objects to return in<br />the <strong class="action">ProfileInfoCollection</strong>. The page index value specifies which page<br />of results to return, where 1 identifies the first page. The parameter for<br />total records is an out parameter (you can use <strong class="action">ByRef</strong> in Visual Basic)<br />that is set to the total number of profiles. For example, if the data store<br />contains 13 profiles for the application and the page index value is 2 with a<br />page size of 5, the <strong class="action">ProfileInfoCollection</strong> returned contains the sixth<br />through the tenth profiles. The total records value is set to 13 when the<br />method returns.</td><br /></tr><br /><tr><br /><td>GetNumberOfInActiveProfiles method</td><br /><td>Takes as input a <strong class="action">ProfileAuthenticationOption</strong> value<br />and a <strong class="action">DateTime</strong> object and returns a count of all profiles in the data<br />source where the last activity date is less than or equal to the specified <strong class="action">DateTime</strong><br />and where the application name matches the <strong class="action">ApplicationName</strong> property<br />value. The <strong class="action">ProfileAuthenticationOption</strong> parameter specifies whether<br />only anonymous profiles, only authenticated profiles, or all profiles are to<br />be counted.</td><br /><br /></tr><br /></tbody></table><br /><br /><h3 style="color: rgb(102, 0, 0); font-weight: normal;"><span style="font-size:100%;">ApplicationName</span></h3>Because profile providers store profile information<br /><p>separately for each application, you must ensure that your data schema includes<br />the application name and that queries and updates also include the application<br />name. For example, the following command is used to retrieve a property value<br />from a database based on the user name and whether the profile is anonymous,<br />and ensures that the <strong class="action">ApplicationName</strong> value<br />is included in the query.</p><br /><br /><pre style="color: rgb(51, 0, 153);">SELECT Property<br />FROM PropertyTable<br />WHERE Username = 'user1'<br />AND IsAnonymous = False<br />AND ApplicationName = 'MyApplication'</pre>Imrankhan Pathanhttp://www.blogger.com/profile/00481180443247674321noreply@blogger.com0