Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 25th, 2007, 5:13 PM   #1
paulchwd
Hobbyist Programmer
 
paulchwd's Avatar
 
Join Date: Mar 2005
Posts: 139
Rep Power: 4 paulchwd is on a distinguished road
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 ?
paulchwd is offline   Reply With Quote
Old Sep 25th, 2007, 5:30 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Sep 25th, 2007, 5:37 PM   #3
paulchwd
Hobbyist Programmer
 
paulchwd's Avatar
 
Join Date: Mar 2005
Posts: 139
Rep Power: 4 paulchwd is on a distinguished road
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();
paulchwd is offline   Reply With Quote
Old Sep 25th, 2007, 8:32 PM   #4
paulchwd
Hobbyist Programmer
 
paulchwd's Avatar
 
Join Date: Mar 2005
Posts: 139
Rep Power: 4 paulchwd is on a distinguished road
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 8:52 PM.
paulchwd is offline   Reply With Quote
Old Sep 25th, 2007, 8:57 PM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Sep 25th, 2007, 10:03 PM   #6
paulchwd
Hobbyist Programmer
 
paulchwd's Avatar
 
Join Date: Mar 2005
Posts: 139
Rep Power: 4 paulchwd is on a distinguished road
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
paulchwd is offline   Reply With Quote
Old Sep 25th, 2007, 10:10 PM   #7
Wizard1988
Professional Programmer
 
Wizard1988's Avatar
 
Join Date: Oct 2005
Location: Chitown
Posts: 422
Rep Power: 4 Wizard1988 is on a distinguished road
public void someFunction()
{
  doStuff();
  doMoreStuff();
  hideDIV();
}
Something like that??
__________________

Wizard1988 is offline   Reply With Quote
Old Sep 25th, 2007, 10:17 PM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Sep 25th, 2007, 10:54 PM   #9
paulchwd
Hobbyist Programmer
 
paulchwd's Avatar
 
Join Date: Mar 2005
Posts: 139
Rep Power: 4 paulchwd is on a distinguished road
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 11:16 PM.
paulchwd is offline   Reply With Quote
Old Sep 26th, 2007, 7:46 AM   #10
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
EXECryptor software protection Jean5 C++ 35 Oct 10th, 2006 8:10 PM
Showing and Hiding Multiple forms crawforddavid2006 C# 4 Sep 13th, 2006 5:24 PM
How to post a question nnxion C++ 10 Jun 3rd, 2005 12:53 PM
How to post a question nnxion C++ 0 Jun 3rd, 2005 9:55 AM
How to post a question nnxion C 0 Jun 3rd, 2005 9:55 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:59 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC