Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 2 .aspx pages . and there are two buttons in first page and two buttons in second page.

In first page one button control is enabled and another is disabled.. when the user clicks on enabled button of first page second page will be displayed.. and on second page user clicks one button.. when this button is clicked i want enable the disabled button of first page..(i.e.,the first page is displayed with both the button controls enabled )

I am using asp.net , C#, visual studio 2005..

Plz help me..

thank u.

regards

karan
Posted
Updated 30-Sep-20 1:11am

Whats stopping you? All sounds straight and simple.

You have various ways to access the 1st page from 2nd, for example:
1. Querystring (if navigating)
2. PreviousPage concept (if not navigating)

All you need is to pass on the flag to one page from other. Did you try at all?
Please do so and do post specific issue, if you face.
 
Share this answer
 
Comments
Venkatesh Mookkan 3-May-11 1:43am    
Good Answer!
Albin Abel 3-May-11 6:30am    
Right What stoping him using a wizard control instead of muddle with pages. My 5 for choices
Sandeep Mewara 3-May-11 7:15am    
Right, wizard control too a good option!
u can pass querystring from second page to first page

on second page button click u can write
response.redirect(firstpage.aspx?id=1);

then on first page load u can do
if(Convert.Tostring(Request.Querystring["id"])=="1")
button.Enabled=true;
 
Share this answer
 
v5
Comments
karan joshua 3-May-11 1:34am    
thank u ashishmanu and s Mewara...

It works...

Thank u once again
Ashishmau 3-May-11 1:37am    
if it works then accept the answer
Venkatesh Mookkan 3-May-11 1:44am    
Good answer. But S Mewara's answer is clean.
Ashishmau 3-May-11 1:56am    
ok, i accept it
in second page

on button click event
    protected void Button1_Click(object sender, EventArgs e)
{
Response.Redrect("Ur firstpage.aspx?id=1");
}


in ur first page in page_load
if(convert.Tostring(Request.Querystring["id"]=="1"s)
{
button1.Enabled=True;
}
else
{
button1.Enabled=False;
}


try it
 
Share this answer
 
This is something you feel not related to your question. But generally Enable/Disable works well for windows application. For asp.net it may not be actually disabled for a hacker. A simple injection of javascript enable the button. So any sensitive branching should not be by the way of simple branching by the UI controls. You need to have a validation at your server side code. Some of the prevention settings you may have is the ValidateRequest attribute at the page tag. For more information refer this

http://www.asp.net/learn/whitepapers/request-validation[^]
 
Share this answer
 
Comments
Abdul Rahman Hamidy 3-May-11 7:16am    
Good Point and very useful.
i think this can be done in much simpler manner without Postback
see here is the demo
Page 1:Disable.htm
XML
<html>
<head>
<title></title>
<script>
    function Disable(controleid) {
        document.getElementById(controleid.id).disabled = true;
        window.open("Enable.htm");
    }
</script>
</head>
<body >
<input type="button" id="one" onclick="Disable(this)" />
</body>
</html>


Page 2:Enable.htm

XML
<html>
<head>
<title></title>
<script>
    function Enabled() {
        window.top.opener.document.getElementById('one').disabled = false;
    }
</script>
</head>
<body >
<input type="button" id="two" onclick="Enabled()" />
</body>
</html>
 
Share this answer
 
In order to disable the button on the second page from the the first page follow the steps as below

1. Declare the session Variable on the first page and then redirect to the Secondpage.aspx
Session["L"] = "0"; // variable declaration
then write response.redirect ("secondPage.apsx") // redirect to the second page

2. Go to the second Page and enter the code on the Page Load section

if (Session["L"].ToString()=="0")
{

myButton.Enabled = false;

}

Thanks
SHAHID AZEEM (Assistant Director NADRA)
 
Share this answer
 
v2
Comments
CHill60 30-Sep-20 10:38am    
You haven't really added anything new to this 9 year old thread

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