Well I have a web page asp.net(page1.aspx) amm user can choose two options A/B if user chooses a when he is in page2.aspx i want a javascript was execute
function(receive parameter)
{
}
But if he chose option B function never will be executed.
I want to do, if user chooses A will see a asp button, but if he ch开发者_StackOverflowoose option b he is not going to be the button
Do you want something like this?
Page 1 - Button 1 (to Page 2 with Button on page 2)
Button 2 (to Page 2 without Button on Page 2)
Page 2
You are using ASP.Net so use the 'Code Behind' and server side controls. The most simplest concept would be to use GET variables, aka QueryStrings.
Create 2 Buttons on Page 1.
<asp:Button ID="Button1" runat="server" onclick="Button1Click"
Text="Button 1" />
<asp:Button ID="Button2" runat="server" onclick="Button2Click"
Text="Button 2" />
Add actions to those buttons (Page 1)
protected void Button1Click(object sender, EventArgs e)
{
Response.Redirect("~/Page2.aspx?Option=1",true);
}
protected void Button2Click(object sender, EventArgs e)
{
Response.Redirect("~/Page2.aspx?Option=2",true);
}
On Page 2 Load event
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["Option"] != null)
{
if (Request.QueryString["Option"] == "1")
{
Response.Write("Option 1");
}
else if (Request.QueryString["Option"] == "2")
{
Response.Write("Option 2");
}
}
}
You could use a querystring parameter...
Page1
protected void Button1_Click(object sender, EventArgs e){
Response.Redirect("~/page2.aspx?showButton=true", true);
}
protected void Button2_Click(object sender, EventArgs e){
Response.Redirect("~/page2.aspx?showButton=false", true);
}
Page2
protected void Page_Load(object sender, EventArgs e){
someButton.Visible = (Request[@"showButton"] == @"true");
}
The example isn't that elegant, but should get you started on what you want.
精彩评论