Jump to content

Dosen't work


jteixeira
 Share

Recommended Posts

You setup the onclick attribute. When you click Button1 the label should disappear. Does this happen? Do you get any javascript errors?Please post the full code for this page and explain exactly what you want to happen

Link to comment
Share on other sites

protected void Page_Load(object sender, EventArgs e)	{		//Imprimir página web corrent		Button1.Attributes.Add("onclick", "document.getElementById('Label1').style.display='none';");		Button1.Attributes.Add("onclick", "window.print();");  		if (Profile.i == "4")		{			Label1.Visible = true;			Button1.Visible = true;			Button2.Visible = true;		}		else		{			Label1.Visible = false;			Button1.Visible = false;			Button2.Visible = false;		}		if (Profile.i == "1" || Profile.i == "2" || Profile.i == "3" || Profile.i == "5" || Profile.i == "6")		{			Button3.Visible = true;		}  }protected void Button1_Click(object sender, EventArgs e)	{	}

when i click in the button the label1 dont' dissappear

Link to comment
Share on other sites

you have set the onclick for Button1 twice. This is causing a conflict. Change these 2 lines

Button1.Attributes.Add("onclick", "document.getElementById('Label1').style.display='none';");		Button1.Attributes.Add("onclick", "window.print();");

into

Button1.Attributes.Add("onclick","document.getElementById('Label1').style.display='none';window.print();");

Link to comment
Share on other sites

okay I think I know what is happening. The print dialog is coming up though, right?try this instead

Button1.Attributes.Add("onclick","document.getElementById('Label1').style.display='none';window.print();return false;");

Without the return false; the PostBack gets fired resetting the label to visible.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...