How to use java script code in user control
-
Hi, i created one user control, in that control i called function. But it is not working when i used that user control in my form. But the same coding can be working in pages. Can any one help me? In my user control i created one table like this,
I write the code in server side as follows, HtmlTableRow htr,htr1; HtmlTableCell htc; htr = new HtmlTableRow(); htc = new HtmlTableCell(); htc.InnerHtml = "Sutheesh Visible"; htr.Cells.Add(htc); SampForum.Controls.Add(htr); htr1 = new HtmlTableRow(); htr1.ID = "Hello"; htc = new HtmlTableCell(); htc.InnerHtml = "Sutheesh Invisible"; htr1.Cells.Add(htc); htr1.Style.Add("display", "none"); htr.Attributes.Add("onClick", "ShowHide('" + htr1.ClientID+ "')"); Ftable.Controls.Add(htr1); JavaScript: function ShowHide(cell) { alert(cell); if(document.getElementById(cell).style.display=="none") document.getElementById(cell).style.display="inline"; else document.getElementById(cell).style.display="none"; }
-
Hi, i created one user control, in that control i called function. But it is not working when i used that user control in my form. But the same coding can be working in pages. Can any one help me? In my user control i created one table like this,
I write the code in server side as follows, HtmlTableRow htr,htr1; HtmlTableCell htc; htr = new HtmlTableRow(); htc = new HtmlTableCell(); htc.InnerHtml = "Sutheesh Visible"; htr.Cells.Add(htc); SampForum.Controls.Add(htr); htr1 = new HtmlTableRow(); htr1.ID = "Hello"; htc = new HtmlTableCell(); htc.InnerHtml = "Sutheesh Invisible"; htr1.Cells.Add(htc); htr1.Style.Add("display", "none"); htr.Attributes.Add("onClick", "ShowHide('" + htr1.ClientID+ "')"); Ftable.Controls.Add(htr1); JavaScript: function ShowHide(cell) { alert(cell); if(document.getElementById(cell).style.display=="none") document.getElementById(cell).style.display="inline"; else document.getElementById(cell).style.display="none"; }
-
Why isn't it working? You haven't stated what the problem is.
Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush
-
Thanks for ur reply friend. The page cannt find document.getElementById(cell), because it (cell) is created in usercontrol.
Member 4755319 wrote:
because it (cell) is created in usercontrol.
Have you checked the page source ? Verify the alert is giving the same name which is there in the page source.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
-
Member 4755319 wrote:
because it (cell) is created in usercontrol.
Have you checked the page source ? Verify the alert is giving the same name which is there in the page source.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions