Disable “warning CS1591: Missing XML comment for publicly visible type or member”
Here i will show you, how you can suppress warnings for XML comments after a Visual Studio build.
Background
If you have checked the “XML documentation file” mark in the Visual Studio project settings, a XML file containing all XML comments is created. Additionally you will get a lot of warnings also in designer generated files, because of the missing or wrong XML comments. While sometimes warnings helps us to improve and stabilize our code, getting hundreds of XML comment warnings is just a pain.
Warnings
Missing XML comment for publicly visible type or member …
XML comment on … has a param tag for ‘…’, but there is no parameter by that name
Parameter ‘…’ has no matching param tag in the XML comment for ‘…’ (but other parameters do)
Solution
You can suppress every warning in Visual Studio.
– Right-click the Visual Studio project / Properties / Build Tab
– Insert the following warning numbers in the “Suppress warnings”: 1591,1572,1571,1573,1587,1570
Clear Text Boxes on a Form with C#
Dears,
In this post i will explain how to Clear Text Boxes Value on a button Click
Clear Text Boxes on a Form with C# using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void BtnClear_Click(object sender, EventArgs e) { CleartextBoxes(this); } public void CleartextBoxes(Control parent) { foreach (Control x in parent.Controls) { if ((x.GetType() == typeof(TextBox))) { ((TextBox)(x)).Text = ""; } if (x.HasControls()) { CleartextBoxes(x); } } } }
Hope this helps
Good Luck.
First Letter In Uppercase in C#
Hi all,
In this post i will show to to convert First Letter to Uppercase in C#
public static string FirstCharToUpper(string value) { char[] array = value.ToCharArray(); // Handle the first letter in the string. if (array.Length >= 1) { if (char.IsLower(array[0])) { array[0] = char.ToUpper(array[0]); } } // Scan through the letters, checking for spaces. // ... Uppercase the lowercase letters following spaces. for (int i = 1; i < array.Length; i++) { if (array[i - 1] == ' ') { if (char.IsLower(array[i])) { array[i] = char.ToUpper(array[i]); } } } return new string(array); }
Hope this helps
Good Luck.
Count number of tables in a SQL Server database
Hi all,
Try this example to Count number of tables in a SQL Server database
USE YOURDBNAME SELECT COUNT(*) from information_schema.tables WHERE table_type = 'base table'
Hope this helps
Good Luck.
Upload a file and attach in email
Hi
try this example
First create new website project and add two pages :-
SendEmail.aspx and EmailSent.aspx
and in the page SendEmail.aspx add three TextBox (txtFrom , txtSubject , txtMessage)
and add button (btn_Send) and Lable control
and Required Validator for txtFrom , txtSubject and Fileupload control
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Web.Mail; using System.IO; public partial class SendEmail : System.Web.UI.Page { string strPath; protected void Page_Load(object sender, EventArgs e) { } private bool SendMail() { try { /* Create a new blank MailMessage */ MailMessage mailMessage = new MailMessage(); mailMessage.From = txtTo.Text; mailMessage.To = "y.ahmed@ewebbers.com"; mailMessage.Subject = txtSubject.Text ; msgMail.Body = txtMessage.Text ; /* We use the following variables to keep track of attachments and after we can delete them */ string attach1 = null; /*strFileName has a attachment file name for attachment process. */ string strFileName = null; if (FileUpload1.PostedFile != null) { /* Get a reference to PostedFile object */ HttpPostedFile attFile = FileUpload1.PostedFile; /* Get size of the file */ int attachFileLength = attFile.ContentLength; /* Make sure the size of the file is > 0 */ if (attachFileLength > 0) { /* Get the file name */ strFileName = Path.GetFileName(FileUpload1.PostedFile.FileName); /* Save the file on the server */ FileUpload1.PostedFile.SaveAs(Server.MapPath(strFileName)); /* Create the email attachment with the uploaded file */ MailAttachment attach = new MailAttachment(Server.MapPath(strFileName)); /* Attach the newly created email attachment */ mailMessage.Attachments.Add(attach); /* Store the attach filename so we can delete it later */ attach1 = strFileName; } /* Set the SMTP server and send the email with attachment */ SmtpMail.SmtpServer = ("SMTP.ewebbers.com"); SmtpMail.Send(mailMessage); /* Delete the attachements if any */ if (attach1 != null) { File.Delete(Server.MapPath(attach1)); } } return true; } catch (Exception ex) { return false; } } protected void btn_Send_Click(object sender, EventArgs e) { bool TrueOrFalse = SendMail(); if ((TrueOrFalse == true)) { Response.Redirect("~/MailSent.aspx"); } else { Label1.Text = "Try again"; } } }
Good Luck
Enable Approve/Reject Function for Approval Workflow in SharePoint
Hi all,
I will show you how to Enable Approve/Reject Function for Approval Workflow in SharePoint 2010
In the settings for the document library or List do the following:
1- Click “Versioning Settings”
2- For “Require content approval for submitted items?” I selected “Yes”
This allowed me to approve and reject the documents or List in the workflow.
Good Luck
Login failed for user IIS APPPOOL\AppPool4.5 or APPPOOL\ASP.NET
Dears,
In this post i will provide a solution for error “Login failed for user IIS APPPOOL\AppPool4.5 or APPPOOL\ASP.NET”
This Error usually occurs when you configure a new website in IIS or move an existing website to a newer version of IIS.
A simple solution to the error is to add a login to SQL Server for IIS APPPOOL\ASP.NET v4.5 and grant appropriate permission to the database.
Open SQL Server Management Studio > Right click ‘Security’ > New > Login
In the dialog that appears, enter the app pool ‘IIS APPPOOL\AppPool4.5’ as the login name then click Ok
Now expand Logins in SSMS and select this newly created login. Right Click > Properties. Click on User mapping and map this login to the database you want to provide access to.
Also select the appropriate roles for this user.
Hope this helps
Good Luck.
Display Progress Bar In GridView
Hi all,
Try this example to display Progress Bar In GridView
<div> <asp:GridView ID="GridView1" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White" runat="server" AutoGenerateColumns="false"> <Columns> <asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="150" /> <asp:BoundField DataField="Percentage" HeaderText="Percentage" ItemStyle-Width="150" /> <asp:TemplateField ItemStyle-Width="300"> <ItemTemplate> <div class='progress'> <div class="progress-label"> <%# Eval("Percentage") %></div> </div> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </div> <style type="text/css"> .ui-progressbar { position: relative; } .progress-label { position: absolute; left: 50%; top: 4px; font-weight: bold; text-shadow: 1px 1px 0 #fff; } body { font-family: Arial; font-size: 10pt; } </style> <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/start/jquery-ui.css"> <script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.js"></script> <script type="text/javascript" src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <script type="text/javascript"> $(function () { $(".progress").each(function () { $(this).progressbar({ value: parseInt($(this).find('.progress-label').text()) }); }); }); </script>
In code behind :
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)), new DataColumn("Name", typeof(string)), new DataColumn("Percentage",typeof(string)) }); dt.Rows.Add(1, "John Hammond", 45); dt.Rows.Add(2, "Mudassar Khan", 37); dt.Rows.Add(3, "Suzanne Mathews", 67); dt.Rows.Add(4, "Robert Schidner", 12); GridView1.DataSource = dt; GridView1.DataBind(); } }
Hope this helps
Good Luck.
Send Email with Attached file in ASP.NET MVC 5
Hello,
In this example i will show how to Send Email with Attached file in ASP.NET MVC 5
1. Create a new Model Class in the model
namespace SendEmailwithAttchedFile.Controllers { public class EmailModel { public string To { get; set; } public string Subject { get; set; } public string Body { get; set; } } }
2. Create a new Home Controller in the Controller and an Email Action with HttpPost method in the Home Controller
using System.IO; using System.Net; using System.Net.Mail; using System.Web; using System.Web.Mvc; namespace SendEmailwithAttchedFile.Controllers { public class HomeController : Controller { [HttpPost] [ActionName("Email")] public ActionResult SendAttachEmail(EmailModel objModelMail, HttpPostedFileBase Attachedfile) { if (ModelState.IsValid) { string from = "youremail@gmail.com"; //Email like- anil.singh581@gmail.com using (MailMessage mail = new MailMessage(from, objModelMail.To)) { mail.Subject = objModelMail.Subject; mail.Body = objModelMail.Body; if (Attachedfile != null) { string fileName = Path.GetFileName(Attachedfile.FileName); mail.Attachments.Add(new Attachment(Attachedfile.InputStream, fileName)); } mail.IsBodyHtml = false; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential networkCredential = new NetworkCredential(from, "your@Password"); smtp.UseDefaultCredentials = true; smtp.Credentials = networkCredential; smtp.Port = 587; smtp.Send(mail); ViewBag.Message = "EmailSent"; return View("Index", objModelMail); } } else { return View(); } } } }
3. In Home View
</pre> @model SendEmailwithAttchedFile.Controllers.EmailModel @{ ViewBag.Title = "Index"; } <h3>Send Email With Attached File</h3> <script src="~/Scripts/jquery-1.10.2.min.js"></script> @using (@Html.BeginForm("Email", "Home", FormMethod.Post, new { @id = "form1", @enctype = "multipart/form-data" })) { @Html.ValidationSummary() <div> <table> <tbody> <tr> <td>To:</td> <td>@Html.TextBoxFor(m => m.To)</td> </tr> <tr> <td>Subject:</td> <td>@Html.TextBoxFor(m => m.Subject)</td> </tr> <tr> <td>Attachment</td> <td><input name="Attachedfile" type="file" /></td> </tr> <tr> <td>Body:</td> <td>@Html.TextAreaFor(m => m.Body)</td> </tr> </tbody> </table> </div> <div><input type="submit" value="Send" /></div> } <script type="text/javascript"> $(function () { if ('@ViewBag.Message' === 'EmailSent') { alert('Email has been sent successfully!'); } }); </script> <pre>
Hope this helps
Solve Error “The query cannot be run for the following DataObject: InfoPath cannot run the specified query. Access is denied”
Dear,
In this post i will show how to Solve error “The query cannot be run for the following DataObject: InfoPath cannot run the specified query. Access is denied”
– Open the form in InfoPath
– Click on File – Form Options
– Click on Security and Trust
– Make sure Full Trust is checked
Hope this helps
Good Luck
Recent Comments