initially a table is invisible in the ASP.NET page. on button click event, it should go to the code behind and from there i need to call a function in javascript. In that javascript function i should make the table to be visible. Is this possible?? Somebody please help me out
7 Answers
try the following code
ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "alert('hello');", true);
Here "this" is used for control by which you want to fire this. this.Gettype() is used get type of Client Script "isActive" it is the unique key. After all these the javascript code. it could be function whatever you want to do. and lastly there is true that ask you either you want to script tag for the javascript code you are writing here or not.
Comments
From code behind you can invoke javascript something like this
ScriptManager.RegisterStartupScript(Page, GetType(Page), "ScriptName", 'document.getelementById("tableId").display = inline;' , True)
But i would recommend to do it on client side without posting a page. Post the page only if you need to access server resources.
1 Comment
alert("Hello"), instead you'd write the script to make your table visible. Just to point things clear.calling javascript functions from code behind is not possible(if we leave apart the newer sockets).
after the page has loaded once fro the web server then there is no way for the server to know what data to send to which user..
you should probably try out sending an ajax request and execute some code depending upon the response got from the server.
<table>) or a ASP.NET Control?