![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Mar 2005
Posts: 139
Rep Power: 4
![]() |
hiding / showing a div from code behind
Hi .. I have a dvi in the aspx page that is set to hidden, I want to set it to visible from my c#code behind file when the execution of the program completes. (and no exceptions are thrown)
how can I do this ? |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Paul, you're asking a train of relatively simple questions. Have you read the documentation (or even Googled)? Just curious.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Mar 2005
Posts: 139
Rep Power: 4
![]() |
Thanks for you reply, I search google extensively, all I could find was how to add javaScript onClick events and such to a button.. i would like to unhide this div after the form data is saved successfully on the database and no exceptions are throw. ie right after command.ExecuteNonQuery();
|
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Mar 2005
Posts: 139
Rep Power: 4
![]() |
I saw code examples with RegisterStartUpScript.. and came up with this code but it doesnt do anything. How can i get the function to execute? Is it possible I can add an onLoad to the form tag (when the user pushes submit, which is also when this code is execute ) from the code-behind so this function will run when the pages loads ? Many thanks
Code behind file string showDiv = " function showDiv() \n" +
"{ \n alert('xx'); \n var myDiv = document.getElementById('fin_div'); \n" +
"myDiv.visibility='visible'; \n" +
"}\n";This is the div code in the aspx file <div id="fin_div" style=" left: 266px; width: 292px; position:relative; top: -708px; background-color: White; height: 131px; visibility:hidden; border-style:dashed; border-width: thin; border-color: Black; visibility:hidden>
<div style="padding-left: 5px; background-image:url(/resources/div_bg.gif); border-bottom-style:solid; border-bottom-width:thin; border-bottom-color: Black; ">
<font face="arial" size="4" color="black"> Complete !</font>
</div>
<div style=" padding:5px;" >
<font face="verdana" size="2" color="black"> <br /> Thank you. You book has been added to BeatTheBookstore. Now buyers can see you book !</font>
</div>
</div>This is what is outputted into the html source: <script type="text/javascript">
<!--
function showDiv()
{
alert('xx');
var myDiv = document.getElementById('fin_div');
myDiv.visibility='visible';
}
// -->
</script>Last edited by paulchwd; Sep 25th, 2007 at 7:52 PM. |
|
|
|
|
|
#5 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
That's fine, Paul, but you have to have something that calls showDiv if the div isn't visible to begin with. The function only does something if it's invoked.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#6 |
|
Hobbyist Programmer
Join Date: Mar 2005
Posts: 139
Rep Power: 4
![]() |
Sorry, I think i was unclear in my last post, and thanks for the response. That is my problem... I am able to write the function to the aspx file, but how do i get something to call it after the code behind file finishes execution ?
Thnx |
|
|
|
|
|
#7 |
|
Professional Programmer
|
public void someFunction()
{
doStuff();
doMoreStuff();
hideDIV();
}
__________________
JG-Webdesign |
|
|
|
|
|
#8 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Have your code behind file generate a call in the HTML. Generally, I put it before the </body> tag, but I might put it in on "on_init" function, if it's called for.
For the first option, just emit, as HTML, <script type="text/javascript">
showDiv ();
</script>
</body>The browser has no idea of what you are doing on the server. When you write your code with a mixture of asp (or PHP, or anything else) and HTML, that is not an interactive scenario where the server does something and the browser does something and the server does something, and so on. That is merely building the page, part of it with textual HTML, and part of it with the server program (asp, or whatever) emitting HTML. When the page is built, it is sent. The browser looks at that page and renders it. If you wonder what the hell your browser is actually seeing, then just view source. That won't necessarily give you everything (the contents of files that you load with style or external script inclusions), but if you really need to see those at the client (you can see them on the server, since you wrote them), then read the RFC's and write a program that loads them just like the browser does. EDIT: That won't work any better, wizard, because the page would still have to call "somefunction".
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#9 |
|
Hobbyist Programmer
Join Date: Mar 2005
Posts: 139
Rep Power: 4
![]() |
It works! It works! Again, thanks for the reply i put a call to it as you said and It worked!
Out of curiosity, how do i stick the call to the function in before the <body> tag programatically.. i just stuck the call in at the top of the script i wrote ie: showDiv(); Function showDiv)( { etc... } Last edited by paulchwd; Sep 25th, 2007 at 10:16 PM. |
|
|
|
|
|
#10 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
The call should be in the body, after the div is rendered.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| EXECryptor software protection | Jean5 | C++ | 35 | Oct 10th, 2006 7:10 PM |
| Showing and Hiding Multiple forms | crawforddavid2006 | C# | 4 | Sep 13th, 2006 4:24 PM |
| How to post a question | nnxion | C++ | 10 | Jun 3rd, 2005 11:53 AM |
| How to post a question | nnxion | C++ | 0 | Jun 3rd, 2005 8:55 AM |
| How to post a question | nnxion | C | 0 | Jun 3rd, 2005 8:55 AM |