Doubt Panel and JS

P

Paulo

Hi, I have asp.net 2.0 C# panel, named: pnlRejeitar on a master page... but
the generated name will be:
ctl00_Contentplaceholder2_grdContratos_ctl02_pnlRejeitar...

I need to do a js function wich hides/shows it on client, not having the
need to do a postback, and I have used the script below, but doesnt work
(object not defined, etc...), why is it happening?

<script>
function hideIt(id) {
//alert('testing');
layer = document.getElementById(id);
layer.style.visibility = "hidden"
}
hideIt('ctl00_Contentplaceholder2_grdContratos_ctl02_pnlRejeitar');
</script>

Thanks!
 
M

Muhammad Naveed Yaseen

Replace
hideIt('ctl00_Contentplaceholder2_grdContratos_ctl02_pnlRejeitar');
with following

hideIt('<%= pnlRejeitar.ClientID %>');

If it still does not work then problem would be in line
layer.style.visibility = "hidden" which appears not to have semicolon
at line end;
 
P

Paulo

Error 5 The name 'pnlRejeitar' does not exist in the current context
C:\Documents and Settings\SUPORTE\Meus documentos\Visual Studio
2005\WebSites\WebSite6\AnaliseContratos.aspx 115
 
M

Muhammad Naveed Yaseen

Ok, I believe the panel is located inside a grid (grdContratos), and
perhaps a separate instance per row. For that you probably would have
to bind the client id dynamically in RowDataBound event.

Like replace hideIt('<%= pnlRejeitar.ClientID %>'); with <asp:Literal
runat="server" id="ltlJSCallProxy" />

Then in RowDataBound event find both this literal and panel by
ltlJSCallProxy = e.Row.FindControl("ltlJSCallProxy") as Literal,,,
and,,, pnlRejeitar = e.Row.FindControl("pnlRejeitar") as Panel.

Once ensuring you have found both in the row (also ensure RowType is
DataRow), set,,, ltlJSCallProxy.Text = string.Format("hideIt('{0});",
pnlRejeitar.ClientID);
 
P

Paulo

Thanks Muhammad for your help, you are right, the panel is inside the
template field on the gridview, but what is a literal?
How can I hide the panel? I didnt understand your example below! Can you
explaing in details? Im using VS 2005 asp.net 2.0...

Thanks a lot...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top