사용자가 버튼을 클릭 할 때 HTML 파일이 VS에서 프로젝트 이름으로 동적으로 생성되고 새 탭에서 열리는 것보다 기능을 만들어야합니다.html의 새 탭에있는 버튼을 클릭하여 동적으로 html 파일을 여는 방법은 무엇입니까?
클라이언트 측에서 내 코드 : 서버 측에서 다음과 같이 내가 디렉토리 코드에서 파일을 만든
<asp:button ID="BtnGenrateHTML" runat="server" text=" Generate HTML " OnClick="btnAddnew_Click" />
: 보호 무효 btnAddnew_Click (개체를 보낸 사람, EventArgs입니다 E) { 문자열 sFileFullName; string sFilePath; string sFileName;
string strHTMLGrid = "";
strHTMLGrid = strHTMLGrid + "Dear Customer,<BR><BR> Please provide below OTP to complete registration <BR><BR> ";
strHTMLGrid = strHTMLGrid + "<BR><BR> This OTP is valid for 15 minutes.";
strHTMLGrid = strHTMLGrid + "<BR><BR> With Best Regards - Indiefy";
This is not working //strHTMLGrid= strHTMLGrid + "<a href="abc.html/">thesitewizard.com</a>"
sFilePath = Server.MapPath("");
sFileName = "abc.html";
sFileFullName = sFilePath + "\\" + sFileName;
if (!Directory.Exists(sFileFullName))
{
Directory.CreateDirectory(sFilePath);
}
// if it exist than to delete it.
if (System.IO.File.Exists(sFileFullName))
{
System.IO.File.Delete(sFileFullName);
}
// If it deleted than we need to create it again
FileStream fs = new FileStream(sFileFullName, FileMode.Create);
using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
{
w.WriteLine(strHTMLGrid);
}
fs.Close();
}
어떻게 버튼의 클릭에 내 abc.html
파일을 열지? 어떻게해야할지 안내해주세요.
이
은 서버 측에서 작동하지 않습니다 :strHTMLGrid= strHTMLGrid + "<a href="abc.html/">thesitewizard.com</a>"
strHTMLGrid = strHTMLGrid + ""; 이것은 작동하지 않습니다 버튼을 클릭하면 Adil은 단지 새로 고칩니다. 아무것도하지 않습니다. window.open과 같은 것입니다. 여기에 글을 쓸 수 있고 url을 전달할 수 있습니다. 코드 뒤에 가능합니다. 알려주세요. 감사합니다. –
업데이트 된 답변을 확인하십시오. – Adil
Page.ClientScript.RegisterStartupScript (this.GetType(), "", "fncpopup();", true); 클라이언트 측에서 함수 함수를 작성한 것보다 fncpopup() { window.open ('abc.html', '_blank'); } 이것은 awsome에게 감사했습니다 –