>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ASP.Net Web Service: The test form is only available for requests from the local machine.
You create a very cool ASP.Net Web Service on your local machine. You are ready to show the world, you deploy it on the server. Then you get the following message "The test form is only available for requests from the local machine. " Here is what you need to fix that.
Open the web config file and add the following, you will be able to access the form outside of the localhost:
<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
</configuration>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Embeded (insert) image into email c# asp.net
Namespaces Used
using System.Net.Mail;
using System.Net.Mime;
CODE
// send mail to the new user who has registered.
protected void yourButton_Click(object sender, EventArgs e)
{
string strMailContent = "Welcome new user";
string fromAddress = "yourname@yoursite.com";
string toAddress = "newuser@hisdomain.com";
string contentId = "image1";
string path = Server.MapPath(@"images/Logo.jpg"); // my logo is placed in images folder
MailMessage mailMessage = new MailMessage( fromAddress, toAddress );
mailMessage.Bcc.Add("inkrajesh@hotmail.com"); // put your id here
mailMessage.Subject = "Welcome new User";
LinkedResource logo = new LinkedResource(path);
logo.ContentId = "companylogo";
// done HTML formatting in the next line to display my logo
AlternateView av1 = AlternateView.CreateAlternateViewFromString("<html><body><img src=cid:companylogo/><br></body></html>" + strMailContent, null, MediaTypeNames.Text.Html);
av1.LinkedResources.Add(logo);
mailMessage.AlternateViews.Add(av1);
mailMessage.IsBodyHtml = true;
SmtpClient mailSender = new SmtpClient("localhost"); //use this if you are in the development server
mailSender.Send(mailMessage);
}
Note:SmtpClient mailSender = new SmtpClient(ConfigurationManager.AppSettings["MyCustomId"]); // use this in the Production Server. I have specified my email server in the web.config file
Remarks
The image may not be displayed in Outlook Express. It worked well when the mail was viewed in Yahoo. If your site is not a trusted one there is a chance that the image may be blocked. It did not work with Hotmail and Gmail.There are other ways to show images, but like many authors have pointed out they do not embed the image. They always refer to the parent site. The image won't be displayed when offline or when the location of the image has changed in the parent site
Thank you , Happy Coding !
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Avoid page Scroll on Post back event in ASP.net
Page.MaintainScrollPositionOnPostBack = true;
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Crystal Report Dynamic Parameter Load Max Records
Crystal Reports XI Release 1
1. Create a registry key HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 12.0\Crystal Reports\DatabaseOptions\LOV.
2. Add a string value "MaxRowsetRecords" and set the value to the maximum number of values that you desire for your report. For example, a value of 2000 will return up to 2000 values in the lowest level of a cascading parameter. NOTE: The value 0 (Unlimited) will not work with BusinessObjects Enterprise XI or Crystal Reports Server XI, you must specify another value.
3. After making changes to the registry, restart the affected service or application as required.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Crate string Using SQL statement
SELECT
MemberList = substring((SELECT ( ', ' + BranchCode + CAST(PolicyYear AS varchar(4)) + '-' + CAST(AAPolicyCodeId AS varchar(10)) )
FROM usrPolicyAll t2
WHERE t1.LifeAsrdId = t2.LifeAsrdId
order by PolicyId
FOR XML PATH( '' )
), 3, 1000 )FROM usrPolicyAll t1 where t1.LifeAsrdId=41314
GROUP BY LifeAsrdId
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Save Image in to Database.
private void ImageSave(object sender,EventArgs e) { string connstr; connstr = ""; // specify your DB conection String //use filestream object to read the image. //read to the full length of image to a byte array. //add this byte as an oracle parameter and insert it into database. string imagename; imagename = textBoxFilePath.Text; try { //proceed only when the image has a valid path if (imagename != "") { FileStream fs; fs = new FileStream(@imagename, FileMode.Open, FileAccess.Read); //a byte array to read the image byte[] picbyte = new byte[fs.Length]; fs.Read(picbyte, 0, System.Convert.ToInt32(fs.Length)); fs.Close(); //open the database using odp.net and insert the data SqlConnection conn = new SqlConnection(connstr); conn.Open(); string query; SqlCommand cmd = conn.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText="sp_insert_ImagesStore"; cmd.Parameters.Add("@ImageData", SqlDbType.Image).Direction = ParameterDirection.Input; cmd.Parameters.Add("@OriginalPath", SqlDbType.VarChar,50).Direction = ParameterDirection.Input; cmd.Parameters.Add("@ItemCode", SqlDbType.VarChar, 50).Direction = ParameterDirection.Input; cmd.Parameters[0].Value = picbyte; cmd.Parameters[1].Value = textBoxFilePath.Text.Trim(); cmd.Parameters[2].Value = textBoxItemCode.Text.Trim(); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); //MessageBox.Show("Image Added"); cmd.Dispose(); conn.Close(); conn.Dispose(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Microsoft SQL Reporting Services from C#, Server report & Client Report for web application
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
/////////////////////// LOCAL REPORT ///////////////////////////////////////////
ReportParameter[] parm = new ReportParameter[3];
parm[0] = new ReportParameter("year");
parm[1] = new ReportParameter("PolicySeq");
parm[2] = new ReportParameter("branch");
//parm[0] = new ReportParameter("AdvisorId", GridView1.Rows[0].Cells[4].Text.Trim());
//parm[1] = new ReportParameter("IsGivenDate", Convert.ToString(CheckBoxGivendate.Checked));
ReportViewer1.ShowCredentialPrompts = false;
ReportViewer1.ShowParameterPrompts = true;
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = "/CCUReminders/PolicyLedger";
ReportViewer1.LocalReport.SetParameters(parm);
ReportViewer1.LocalReport.Refresh();
/////////////////////// SERVER REPORT ///////////////////////////////////////////
ReportParameter[] parm = new ReportParameter[3];
parm[0] = new ReportParameter("year");
parm[1] = new ReportParameter("PolicySeq");
parm[2] = new ReportParameter("branch");
ReportViewer1.ShowCredentialPrompts = false;
ReportViewer1.ShowParameterPrompts = true;
ReportViewer1.ServerReport.ReportServerCredentials = new PolicyLedgerNewCredentials("Reportfolder Name", "Password of the folder", "");
ReportViewer1.ServerReport.ReportServerCredentials = new PolicyLedgerNewCredentials("Administrator", "12345678", "");
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
ReportViewer1.ServerReport.ReportServerUrl = new System.Uri("http://10.25.8.56/ReportServer");
ReportViewer1.ServerReport.ReportPath = "/CCUReminders/PolicyLedger";
ReportViewer1.ServerReport.SetParameters(parm);
ReportViewer1.ServerReport.Refresh();
///////////////////////////////////////////////////////////////////////////////////
/// ADD FOLLOWING CLASS IF IT IS A SERVER REPORT
public class PolicyLedgerNewCredentials : IReportServerCredentials
{
string _userName, _password, _domain;
public PolicyLedgerNewCredentials(string userName, string password, string domain)
{
_userName = userName;
_password = password;
_domain = domain;
}
public System.Security.Principal.WindowsIdentity ImpersonationUser
{
get
{
return null;
}
}
public System.Net.ICredentials NetworkCredentials
{
get
{
return new System.Net.NetworkCredential(_userName, _password, _domain);
}
}
public bool GetFormsCredentials(out System.Net.Cookie authCoki, out string userName, out string password, out string authority)
{
userName = _userName;
password = _password;
authority = _domain;
authCoki = new System.Net.Cookie(".ASPXAUTH", ".ASPXAUTH", "/", "Domain");
return true;
}
}
/////////////////////////////////////////////////////////////////////////////
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Microsoft SQL Reporting Services from C#, Server report & Client Report for web application
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
/////////////////////// LOCAL REPORT ///////////////////////////////////////////
ReportParameter[] parm = new ReportParameter[3];
parm[0] = new ReportParameter("year");
parm[1] = new ReportParameter("PolicySeq");
parm[2] = new ReportParameter("branch");
//parm[0] = new ReportParameter("AdvisorId", GridView1.Rows[0].Cells[4].Text.Trim());
//parm[1] = new ReportParameter("IsGivenDate", Convert.ToString(CheckBoxGivendate.Checked));
ReportViewer1.ShowCredentialPrompts = false;
ReportViewer1.ShowParameterPrompts = true;
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = "/CCUReminders/PolicyLedger";
ReportViewer1.LocalReport.SetParameters(parm);
ReportViewer1.LocalReport.Refresh();
/////////////////////// SERVER REPORT ///////////////////////////////////////////
ReportParameter[] parm = new ReportParameter[3];
parm[0] = new ReportParameter("year");
parm[1] = new ReportParameter("PolicySeq");
parm[2] = new ReportParameter("branch");
ReportViewer1.ShowCredentialPrompts = false;
ReportViewer1.ShowParameterPrompts = true;
ReportViewer1.ServerReport.ReportServerCredentials = new PolicyLedgerNewCredentials("Reportfolder Name", "Password of the folder", "");
ReportViewer1.ServerReport.ReportServerCredentials = new PolicyLedgerNewCredentials("Administrator", "12345678", "");
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
ReportViewer1.ServerReport.ReportServerUrl = new System.Uri("http://10.25.8.56/ReportServer");
ReportViewer1.ServerReport.ReportPath = "/CCUReminders/PolicyLedger";
ReportViewer1.ServerReport.SetParameters(parm);
ReportViewer1.ServerReport.Refresh();
///////////////////////////////////////////////////////////////////////////////////
/// ADD FOLLOWING CLASS IF IT IS A SERVER REPORT
public class PolicyLedgerNewCredentials : IReportServerCredentials
{
string _userName, _password, _domain;
public PolicyLedgerNewCredentials(string userName, string password, string domain)
{
_userName = userName;
_password = password;
_domain = domain;
}
public System.Security.Principal.WindowsIdentity ImpersonationUser
{
get
{
return null;
}
}
public System.Net.ICredentials NetworkCredentials
{
get
{
return new System.Net.NetworkCredential(_userName, _password, _domain);
}
}
public bool GetFormsCredentials(out System.Net.Cookie authCoki, out string userName, out string password, out string authority)
{
userName = _userName;
password = _password;
authority = _domain;
authCoki = new System.Net.Cookie(".ASPXAUTH", ".ASPXAUTH", "/", "Domain");
return true;
}
}
/////////////////////////////////////////////////////////////////////////////
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<