Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

Doubt Panel and JS

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paulo - 03 Sep 2007 21:03 GMT
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!
Muhammad Naveed Yaseen - 03 Sep 2007 21:40 GMT
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;
Paulo - 03 Sep 2007 22:10 GMT
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

> Replace
> hideIt('ctl00_Contentplaceholder2_grdContratos_ctl02_pnlRejeitar');
[quoted text clipped - 5 lines]
> layer.style.visibility = "hidden" which appears not to have semicolon
> at line end;
Muhammad Naveed Yaseen - 03 Sep 2007 22:56 GMT
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);
Paulo - 04 Sep 2007 12:51 GMT
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...

> Ok, I believe the panel is located inside a grid (grdContratos), and
> perhaps a separate instance per row. For that you probably would have
[quoted text clipped - 10 lines]
> DataRow), set,,, ltlJSCallProxy.Text = string.Format("hideIt('{0});",
> pnlRejeitar.ClientID);

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.