Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have multiple resume templates (html) in my project.
I want to replace thier values e.g. #Name# with my database value
Can u please tell me the whole code ?
I am doing as...
C#
protected void btnGenerateResume_Click(object sender, EventArgs e)
        {
            string selectedtemplate = "template01";
            if (rdoTemplate01.Checked)
            {
                selectedtemplate = "template01";
            }
            if (rdoTemplate02.Checked)
            {
                selectedtemplate = "template02";
            }
            if (rdoTemplate03.Checked)
            {
                selectedtemplate = "template03";
            }
            if (rdoTemplate04.Checked)
            {
                selectedtemplate = "template04";
            }
            if (rdoTemplate05.Checked)
            {
                selectedtemplate = "template05";
            }
            if (rdoTemplate06.Checked)
            {
                selectedtemplate = "template06";
            }
            if (rdoTemplate07.Checked)
            {
                selectedtemplate = "template07";
            }
            if (rdoTemplate08.Checked)
            {
                selectedtemplate = "template08";
            }
            int memberId = Convert.ToInt32(Session["_memberid"]);

            try
            {
                using (ZeumayDBEntities _zentity = new ZeumayDBEntities())
                {

                    Tbl_Zeumay _tblzeumay = _zentity.Tbl_Zeumay.Where(x => x.member_id == memberId).First();

                    FileStream _fAppStream = File.Open(Server.MapPath(@Common.GetTemplate(selectedtemplate)), FileMode.Open);
                    byte[] _appBuffer = new byte[_fAppStream.Length + 1];
                    _fAppStream.Read(_appBuffer, 0, _appBuffer.Length);
                    string _fAppContent = System.Text.Encoding.UTF7.GetString(_appBuffer);
                    _fAppContent = _fAppContent.Substring(_fAppContent.IndexOf("selectedtemplate"));
                    _fAppStream.Close();
                    _fAppContent = _fAppContent.Replace("#Phone#", _tblzeumay.Tbl_Member.member_phone);
                    _fAppContent = _fAppContent.Replace("#FirstName#", _tblzeumay.Tbl_Member.member_first_name);
                    _fAppContent = _fAppContent.Replace("#LastName#", _tblzeumay.Tbl_Member.member_last_name);

                    _fAppContent = _fAppContent.Replace("#ResumeHeading#", _tblzeumay.Tbl_Professional_Detail.headline);
                    _fAppContent = _fAppContent.Replace("#Objective#", _tblzeumay.Tbl_Professional_Detail.my_objective);
                    _fAppContent = _fAppContent.Replace("#Skills#", _tblzeumay.Tbl_Professional_Detail.key_skills);
                    _fAppContent = _fAppContent.Replace("#Address1#", _tblzeumay.Tbl_Member.Tbl_Member_Address.address1);
                    _fAppContent = _fAppContent.Replace("#Address2#", _tblzeumay.Tbl_Member.Tbl_Member_Address.address2);
                    _fAppContent = _fAppContent.Replace("#CityName#", _tblzeumay.Tbl_Member.Tbl_Member_Address.Tbl_City.city_name);
                    _fAppContent = _fAppContent.Replace("#StateName#", _tblzeumay.Tbl_Member.Tbl_Member_Address.Tbl_State.state_name);
                    _fAppContent = _fAppContent.Replace("#Email#", _tblzeumay.Tbl_Member.member_email_id);
                    _fAppContent = _fAppContent.Replace("#ExpYears#", _tblzeumay.Tbl_Professional_Detail.experiance_year.ToString());
                    _fAppContent = _fAppContent.Replace("#ExpMonths#", _tblzeumay.Tbl_Professional_Detail.experiance_month.ToString());
                    _fAppContent = _fAppContent.Replace("#EducationalDetails#", _tblzeumay.Tbl_Eduactional_Detail.Tbl_Graduate.graduate_name);
                    _fAppContent = _fAppContent.Replace("#SpokenLanguages#", "hindi");
                    _fAppContent = _fAppContent.Replace("#DOB#", _tblzeumay.Tbl_Member.member_dob.ToString());
                    _fAppContent = _fAppContent.Replace("#City#", _tblzeumay.Tbl_Member.Tbl_Member_Address.Tbl_City.city_name);
                    _fAppContent = _fAppContent.Replace("#State#", _tblzeumay.Tbl_Member.Tbl_Member_Address.Tbl_State.state_name);
                    TextWriter _fWriter = new StreamWriter(Server.MapPath(@"Resume/" + "Resume_" + Session["_memberid"].ToString() + ".html"));
                    //  String line = _fAppContent.ReadToEnd();
                    Text2PDF(_fAppContent);
                    Response.Write("Your Resume has been created automatically");
                    _fWriter.Write(_fAppContent);
                    _fWriter.Close();
                }
            }

but its giving an error at Get Template line.
Posted
v2
Comments
n.podbielski 21-Nov-12 3:31am    
What type is @Common.GetTemplate?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900