Show/hide Div tag in popup window???
-
Hi all, I have a div tag in my user control, and I want to show/hide this div based on which page I am on. So here is what I have now. in .ascx page,
....content
in ascx.cs page: public string ReturnVisibility() { string class= "CssShowDiv"; if (Page.Request.Url.ToString().IndexOf("page1.aspx") > 0) { class= "CssHideDiv"; } return class; } The result is that it works fine in a normal window. But if I open the page in a popup window using javascript, the div tag content always shows on the page, even though the class is CssHideDiv. Can anybody give me a hint what's wrong with my code? Thank you very much!
-
Hi all, I have a div tag in my user control, and I want to show/hide this div based on which page I am on. So here is what I have now. in .ascx page,
....content
in ascx.cs page: public string ReturnVisibility() { string class= "CssShowDiv"; if (Page.Request.Url.ToString().IndexOf("page1.aspx") > 0) { class= "CssHideDiv"; } return class; } The result is that it works fine in a normal window. But if I open the page in a popup window using javascript, the div tag content always shows on the page, even though the class is CssHideDiv. Can anybody give me a hint what's wrong with my code? Thank you very much!
-
Half of your code doesn't show up. Use the "Ignore HTML" option when you are posting markup code.
Experience is the sum of all the mistakes you have done.
Hi all, I have a div tag in my user control, and I want to show/hide this div based on which page I am on. So here is what I have now. in .ascx page,
....content
in ascx.cs page: public string ReturnVisibility() { string class= "CssShowDiv"; if (Page.Request.Url.ToString().IndexOf("page1.aspx") > 0) { class= "CssHideDiv"; } return class; } The result is that it works fine in a normal window. But if I open the page in a popup window using javascript, the div tag content always shows on the page, even though the class is CssHideDiv. Can anybody give me a hint what's wrong with my code? Thank you very much!
-
Hi all, I have a div tag in my user control, and I want to show/hide this div based on which page I am on. So here is what I have now. in .ascx page,
....content
in ascx.cs page: public string ReturnVisibility() { string class= "CssShowDiv"; if (Page.Request.Url.ToString().IndexOf("page1.aspx") > 0) { class= "CssHideDiv"; } return class; } The result is that it works fine in a normal window. But if I open the page in a popup window using javascript, the div tag content always shows on the page, even though the class is CssHideDiv. Can anybody give me a hint what's wrong with my code? Thank you very much!
I guess, maybe. the path of CSS file in popup window is wrong??
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) "Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
-
Hi all, I have a div tag in my user control, and I want to show/hide this div based on which page I am on. So here is what I have now. in .ascx page,
....content
in ascx.cs page: public string ReturnVisibility() { string class= "CssShowDiv"; if (Page.Request.Url.ToString().IndexOf("page1.aspx") > 0) { class= "CssHideDiv"; } return class; } The result is that it works fine in a normal window. But if I open the page in a popup window using javascript, the div tag content always shows on the page, even though the class is CssHideDiv. Can anybody give me a hint what's wrong with my code? Thank you very much!
vicky457 wrote:
in ascx.cs page: public string ReturnVisibility() { string class= "CssShowDiv";
No, that's not the code that you are using. You can't name a variable "class", so that code doesn't even compile. Show the code that you are actually using. I can't see what's wrong with the code that you are using by looking at some other code that you are not using.
vicky457 wrote:
if (Page.Request.Url.ToString().IndexOf("page1.aspx") > 0)
If you have as condition that the value that IndexOf returns should be greater than zero, that means that if the string is found at the first position in the url, the condition will be false. Not that the url is likely to be only the page name, but you should be aware of it.
vicky457 wrote:
The result is that it works fine in a normal window. But if I open the page in a popup window using javascript, the div tag content always shows on the page, even though the class is CssHideDiv.
The server isn't even aware that the page will be shown in a popup, and none of the code that you have shown would act any different in a popup, so the problem is in some of the code that you haven't shown.
Experience is the sum of all the mistakes you have done.
-
vicky457 wrote:
in ascx.cs page: public string ReturnVisibility() { string class= "CssShowDiv";
No, that's not the code that you are using. You can't name a variable "class", so that code doesn't even compile. Show the code that you are actually using. I can't see what's wrong with the code that you are using by looking at some other code that you are not using.
vicky457 wrote:
if (Page.Request.Url.ToString().IndexOf("page1.aspx") > 0)
If you have as condition that the value that IndexOf returns should be greater than zero, that means that if the string is found at the first position in the url, the condition will be false. Not that the url is likely to be only the page name, but you should be aware of it.
vicky457 wrote:
The result is that it works fine in a normal window. But if I open the page in a popup window using javascript, the div tag content always shows on the page, even though the class is CssHideDiv.
The server isn't even aware that the page will be shown in a popup, and none of the code that you have shown would act any different in a popup, so the problem is in some of the code that you haven't shown.
Experience is the sum of all the mistakes you have done.
I have the following in .aspx page:
The OpenSuin .js file function OpenSummaryPage() { with(aspnetForm) { var url ="summary.aspx?comment=" + hdShowComment.value; window.open(url); } } The function in ascx.cs page is actually like this: public string ReturnVisibility() { string divCssClass= "CssShowDiv"; if (Page.Request.Url.ToString().IndexOf("page1.aspx") > 0) { divCssClass= "CssHideDiv"; } return divCssClass; } In .css file: .CssShowDiv{DISPLAY: true} .CssHideDiv{DISPLAY: none} Thanks for help!
-
I have the following in .aspx page:
The OpenSuin .js file function OpenSummaryPage() { with(aspnetForm) { var url ="summary.aspx?comment=" + hdShowComment.value; window.open(url); } } The function in ascx.cs page is actually like this: public string ReturnVisibility() { string divCssClass= "CssShowDiv"; if (Page.Request.Url.ToString().IndexOf("page1.aspx") > 0) { divCssClass= "CssHideDiv"; } return divCssClass; } In .css file: .CssShowDiv{DISPLAY: true} .CssHideDiv{DISPLAY: none} Thanks for help!
vicky457 wrote:
The
javascript:
protocol is only used if you put the Javascript in an url. If you use it anywhere else, it isn't recognised as a protocol but it becomes a label instead. As you are using xhtml, argument names have to be lower case.<img src="btn_print.gif" onclick="OpenSummaryPage();"/>
vicky457 wrote:
var url ="summary.aspx?comment=" + hdShowComment.value;
Use the getElementById to access elements in the page.
var url = "summary.aspx?comment=" + document.getElementById('hdShowComment').value;
vicky457 wrote:
.CssShowDiv{DISPLAY: true}
"true" is not a valid value for the
display
style. Use the value "block" to display a block element (e.g. a div) and the value "inline" to display an inline element (e.g. a span). Have you verified that the css really is used on the page? You can for example add a background color or a border to some element on the page to see if it's used. Css files are cached longer than pages, so an older version of the css file might be used. Press ctrl+F5 to reload the page and all files it uses.Experience is the sum of all the mistakes you have done.
-
vicky457 wrote:
in ascx.cs page: public string ReturnVisibility() { string class= "CssShowDiv";
No, that's not the code that you are using. You can't name a variable "class", so that code doesn't even compile. Show the code that you are actually using. I can't see what's wrong with the code that you are using by looking at some other code that you are not using.
vicky457 wrote:
if (Page.Request.Url.ToString().IndexOf("page1.aspx") > 0)
If you have as condition that the value that IndexOf returns should be greater than zero, that means that if the string is found at the first position in the url, the condition will be false. Not that the url is likely to be only the page name, but you should be aware of it.
vicky457 wrote:
The result is that it works fine in a normal window. But if I open the page in a popup window using javascript, the div tag content always shows on the page, even though the class is CssHideDiv.
The server isn't even aware that the page will be shown in a popup, and none of the code that you have shown would act any different in a popup, so the problem is in some of the code that you haven't shown.
Experience is the sum of all the mistakes you have done.
Guffa wrote:
No, that's not the code that you are using.
good caught... I didn't notice that one.. great answer..
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) "Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
-
vicky457 wrote:
The
javascript:
protocol is only used if you put the Javascript in an url. If you use it anywhere else, it isn't recognised as a protocol but it becomes a label instead. As you are using xhtml, argument names have to be lower case.<img src="btn_print.gif" onclick="OpenSummaryPage();"/>
vicky457 wrote:
var url ="summary.aspx?comment=" + hdShowComment.value;
Use the getElementById to access elements in the page.
var url = "summary.aspx?comment=" + document.getElementById('hdShowComment').value;
vicky457 wrote:
.CssShowDiv{DISPLAY: true}
"true" is not a valid value for the
display
style. Use the value "block" to display a block element (e.g. a div) and the value "inline" to display an inline element (e.g. a span). Have you verified that the css really is used on the page? You can for example add a background color or a border to some element on the page to see if it's used. Css files are cached longer than pages, so an older version of the css file might be used. Press ctrl+F5 to reload the page and all files it uses.Experience is the sum of all the mistakes you have done.
I just found out the problem is caused by a stupid mistake. There is duplicated CssClass is defined, one is in Master page and is called CssHideDiv, the other is in .css file and is called CssHiddenDiv. The open widnow is not using master page, but is using CssHideDiv. This is a mistake introduced by multiple developers defining the same css class. Thanks for everybody's help! I appreciate it!