弹出asp.net页面,javascript和路径错误404
我有这个问题。两个页面:一个父页面和一个子页面,由 javascript 在弹出窗口中调用。 子页面是搜索页面。在此用户可以选择结果之一并通过查询字符串和 JavaScript 将其重新发送到父页面。
这是我用来在 search.aspx 的代码隐藏中执行此操作的脚本:
protected void Button4_Click(object sender, EventArgs e)
{
string url2 = "";
if (GridView1.Rows.Count == 0)
{
string myStringVariable = string.Empty;
myStringVariable = "Nessuna ricerca effettuata!";
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true);
}
else
{
bool chk = false;
foreach (GridViewRow row in GridView1.Rows)
{
RadioButton rad = (RadioButton)row.FindControl("RadioButton1");
Label lb1 = (Label)row.FindControl("Label1");
if (rad.Checked)
{
chk = true;
url2 = "classmer.aspx?cod=" + lb1.Text;
break;
}
}
if (chk)
{
StringBuilder st = new StringBuilder();
st.Append("<script language='javascript'>");
st.Append("window.opener.location = '" + url2 + "';");
st.Append("self.close();");
st.Append("</script>");
ClientScript.RegisterStartupScript(typeof(Page), "", st.ToString());
}
else if (!chk)
{
string myStringVariable = string.Empty;
myStringVariable = "Nessun mercato selezionato!";
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true);
}
}
现在让我们讨论 404 错误。 父页面的网址为“http://localhost/App/ClassMer/classmer.aspx” 子页面具有此 url“http://localhost/App/ClassMer/search.aspx”
通过单击搜索页面上的确认按钮, ,它会绕过该 url“http://localhost/ClassMer/classmer.aspx”重新发送“App”文件夹(这是部署应用程序时在 IIS7 中创建的虚拟路径。)
如何解决此问题?
我尝试了一些解决方案,例如添加 Request.ApplicationPath 或直接通过字符串指定我传递给 javascript 的 url 路径,但没有发生。
请帮助!
谢谢
I've this problem. Two pages: a parent and a child called in popup window by javascript.
The child page is a search page. In this user can select one of the results and resend it to the parent page by querystring and javascript.
this is the script I use to do this in codebehind of search.aspx:
protected void Button4_Click(object sender, EventArgs e)
{
string url2 = "";
if (GridView1.Rows.Count == 0)
{
string myStringVariable = string.Empty;
myStringVariable = "Nessuna ricerca effettuata!";
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true);
}
else
{
bool chk = false;
foreach (GridViewRow row in GridView1.Rows)
{
RadioButton rad = (RadioButton)row.FindControl("RadioButton1");
Label lb1 = (Label)row.FindControl("Label1");
if (rad.Checked)
{
chk = true;
url2 = "classmer.aspx?cod=" + lb1.Text;
break;
}
}
if (chk)
{
StringBuilder st = new StringBuilder();
st.Append("<script language='javascript'>");
st.Append("window.opener.location = '" + url2 + "';");
st.Append("self.close();");
st.Append("</script>");
ClientScript.RegisterStartupScript(typeof(Page), "", st.ToString());
}
else if (!chk)
{
string myStringVariable = string.Empty;
myStringVariable = "Nessun mercato selezionato!";
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true);
}
}
now let's pass to the 404 error.
the parent page has this url "http://localhost/App/ClassMer/classmer.aspx"
the child page has this url "http://localhost/App/ClassMer/search.aspx"
by clicking the confirm button on search page, it resend to this url "http://localhost/ClassMer/classmer.aspx" bypassing the "App" folder (that is a virtal path created in IIS7 when deploying the application.)
how can I resolve this?
I tried some solution like adding Request.ApplicationPath or directly specifing by string the path to the url I pass to javascript but none happened.
Help, please!!
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想
Request.ApplicationPath
应该没问题。请尝试以下操作:Request.ApplicationPath
should be fine I'd have thought. Try the following: