![]() |
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 ? |
Paul, you're asking a train of relatively simple questions. Have you read the documentation (or even Googled)? Just curious.
|
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();
|
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" + 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>This is what is outputted into the html source: :
<script type="text/javascript"> |
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.
|
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 |
:
public void someFunction() |
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">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". |
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... } |
The call should be in the body, after the div is rendered.
|
| All times are GMT -5. The time now is 3:05 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC