replace texbox values inside an html template

前端 未结 2 1471
北恋
北恋 2021-01-29 12:42

i have some textboxes.. when \'preview\' button is clicked it goes to another page which contains an html template.. i need to replace the textbox entered values inside the temp

相关标签:
2条回答
  • 2021-01-29 12:54

    try this out

         FileStream fs = new FileStream(**TemplateFileNamegoesHere**,FileMode.Open);
    
        StreamReader fr = new StreamReader(fs);
        string data = fr.ReadToEnd();
        string data=data.Replace(" [mg-from]", txtfrom.text );
    

    it will replace the "[mg-from]" to given txtfrom.text value try and let me know

    0 讨论(0)
  • 2021-01-29 13:02
    public partial class EmployeePortal_CommunicationPreview : System.Web.UI.Page
    {
    
        protected void Page_Load(object sender, EventArgs e)
        {
    
    
            System.IO.FileStream fs = new FileStream("~/Auto-Emails/Internalcommunication.htm", FileMode.Open);
    
            StreamReader fr = new StreamReader(fs);
            string data = fr.ReadToEnd();
            string from  = data.Replace(" [mg-from]", txtfrom.text);
    
        }
    }
    

    here the txtfrom.text belongs to the first page... i need to pass the txtfrom of the first page to the second page replacing [mg-from]... how will i do ??

    0 讨论(0)
提交回复
热议问题