how to hide a webuser control through javascript

srinivas76

New member
Joined
Apr 15, 2009
Messages
1
Programming Experience
3-5
I have application like developing a in gridview column webusercontrol calender (for 3 months)
first time total column invisible ,when user is clicking a button on gridview the webusercontrol calender should be visible clicking row only.

javascript as follows:


VB.NET:
function VisbleControl(i,j) 
{

	if(parseInt(i)<10) 
	{
		controlrow1=document.getElementById("ctl00_ContentPlaceHolder1_GridView1_ctl0" + i +"_WebUserControl1_Panel1"); 
	}
	else
	{
	    controlrow1=document.getElementById("ctl00_ContentPlaceHolder1_GridView1_ctl" + i +"_WebUserControl1_Panel1");
	}
	
	
		
	if (controlrow1.style.display== "none")
	{
	controlrow1.style.display="block"; 
	}
	else
	{
	controlrow1.style.display= "none";  
	}
	
	
}

above code works clicking row ok , but another rows also web calender controls also visible

webusercontrol code:


HTML:
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" 
CodeFile="frmAdSearchResult.aspx.vb" Inherits="frmAdSearchResult" title="MCP Dashborad :: Ad Search Result"  Theme="MCPADTheme"%>

<%@ Register Src="WebUserControl.ascx" TagName="WebUserControl" TagPrefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script type="text/javascript">
function showFocusdates()
{

  window.open("frmFocusDates.aspx?strSelIndex=0","mywindow","menubar=0,resizable=0,scrollbars=0,status=1,toolbar=0,height=300,width=700,top=300px,left=200px"); 
 
}
function showPreview()
{
 window.open("frmFocusDates.aspx?strSelIndex=0","mywindow","menubar=0,resizable=0,scrollbars=0,status=1,toolbar=0,height=400,width=700,top=300px,left=200px"); 
    //window.open("frmAdPreview.aspx","mywindow","menubar=0,resizable=0,scrollbars=0,status=1,toolbar=0,height=150,width=500,top=300px,left=200px"); 
}



function calc(i,j) 
{
	
	
//	for(j=2;j<=3;j++)
//{
//	    if(j<10)
//    {
//	    	controlrow1=document.getElementById("ctl00_ContentPlaceHolder1_GridView1_ctl0" + j +"_WebUserControl1_Panel1"); 
//	     
//	    }
//	    else
//	    {
//	        controlrow1=document.getElementById("ctl00_ContentPlaceHolder1_GridView1_ctl" + j +"_WebUserControl1_Panel1");
//    }
//	    
//	    controlrow1.style.display== "none";   
//	  
//	
//	}
	
	
	if(parseInt(i)<10) 
	{
		controlrow1=document.getElementById("ctl00_ContentPlaceHolder1_GridView1_ctl0" + i +"_WebUserControl1_Panel1"); 
	}
	else
	{
	    controlrow1=document.getElementById("ctl00_ContentPlaceHolder1_GridView1_ctl" + i +"_WebUserControl1_Panel1");
	}
	
	
		
	if (controlrow1.style.display== "none")
	{
	controlrow1.style.display="block"; 
	}
	else
	{
	controlrow1.style.display= "none";  
	}
	
	
}


function callenderInvisble(i)
    {
    
    
    
    
       
        
                if(parseInt(i)<10) 
	            {
		            controlrow2=document.getElementById("ctl00_ContentPlaceHolder1_GridView1_ctl0" + i +"_WebUserControl1_Panel1"); 
	            }
	            else
	            {
	                controlrow2=document.getElementById("ctl00_ContentPlaceHolder1_GridView1_ctl" + i +"_WebUserControl1_Panel1");
	            }
            	
                controlrow2.style.display= "none";  
      
    }



</script>
                          




 <table style="width: 100%">
        <tr>
            <td align="right" colspan="2">
                <input id="Button1" type="button" value="Back" onclick="window.history.back(1)" />
                  </td>
        </tr>
        <tr>
            <td colspan="2" >
                Search Result:</td>
        </tr>
        <tr>
            <td colspan="2" style="height: 21px" >
                <asp:Label ID="lblMsg" runat="server"></asp:Label></td>
        </tr>
        <tr>
            <td colspan="2" >
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="f_banner_id" >
                    <Columns>
                        <asp:BoundField DataField="CATEGORY" HeaderText="Category" >
                            <ItemStyle VerticalAlign="Top" />
                        </asp:BoundField>
                        <asp:BoundField DataField="LOCATION" HeaderText="SubCategory" >
                            <ItemStyle VerticalAlign="Top" />
                        </asp:BoundField>
                        <asp:BoundField DataField="banner" HeaderText="Banner" >
                            <ItemStyle VerticalAlign="Top" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Price" HeaderText="Price(One,Two,Three)" >
                            <ItemStyle VerticalAlign="Top" />
                        </asp:BoundField>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <img src="Images/preview.jpg" style="width: 65px" id="Img7" onclick="showPreview()" />
                            </ItemTemplate>
                            <ItemStyle VerticalAlign="Top" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Selected Dates">
                            <ItemTemplate>
                                 <asp:Label ID="lblDate1" runat="server"></asp:Label>
                <asp:Label ID="lblDate2" runat="server"></asp:Label>
                <asp:Label ID="lblDate3" runat="server"></asp:Label>
                            </ItemTemplate>
                            <ItemStyle VerticalAlign="Top" />
                        </asp:TemplateField>
                        <asp:CommandField ButtonType="Image" SelectImageUrl="~/Images/calendar.jpg" ShowSelectButton="True" >
                            <ItemStyle VerticalAlign="Top" />
                        </asp:CommandField>
                      
                      
                      <asp:TemplateField>
                            <ItemTemplate>
                            
                                
                               <%--   <asp:Button ID="btnCalender" runat="server" Text="Button"  />--%>
                          <asp:Image ID="imgCalender" runat="server" ImageUrl="~/Images/calendar.jpg" />
                       </ItemTemplate>
                          <ItemStyle VerticalAlign="Top" />
                        </asp:TemplateField>
                        
                        
                      <asp:TemplateField>
                            <ItemTemplate>
                                 <uc1:WebUserControl ID="WebUserControl1" runat="server" Visible ="True"  />
                                
                             </ItemTemplate>
                          <ItemStyle VerticalAlign="Top" />
                        </asp:TemplateField>
                            
                       
                                                               
                     
                       
                    </Columns>
                </asp:GridView>
                
               
                </td>
        </tr>
        <tr>
            <td align="center" colspan="2" style="height: 33px" >
                <asp:Button ID="btnSave" runat="server" Text="Save & Continue" /> 
                </td>
        </tr>
     <tr>
         <td align="center" colspan="2" style="height: 300px">
             <asp:Button ID="Button2" runat="server" Text="Button" />
             <asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
             <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
               
         </td>
     </tr>
    </table>
</asp:Content>
 
Last edited by a moderator:
Back
Top