Click here to Skip to main content
15,895,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is aspx page


ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="hyperlink.aspx.cs" Inherits="hyperlink" %>
<%@ Register Src="~/hyperlinkusercontrol.ascx" tagname="abc" tagprefix="uc1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   <uc1:abc id="abc"  runat="server" visible=true/>
    </div>
    <p>
        <asp:LinkButton ID="LinkButton1" runat="server">LinkButton
    </p>
    <p>
         </p>
    <p>
         </p>
    <p>
         </p>
    </form>
</body>
</html>


this is ascx page

XML
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="hyperlinkusercontrol.ascx.cs" Inherits="hyperlinkusercontrol" %>
<style type="text/css">
    .style1
    {
        width: 100%;
    }
    .style2
    {
        width: 63px;
    }
</style>

<table class="style1">
    <tr>
        <td class="style2">
            User</td>
        <td>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td class="style2">
            pwd</td>
        <td>
            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td class="style2">
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        </td>
        <td>
            <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
        </td>
    </tr>
</table>


this is ascx.cs

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Configuration;

public partial class hyperlinkusercontrol : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if(TextBox1.Text=="mann"&& TextBox2.Text=="rai")
        {
            Label1.Text = "helloo welcm";
        }
        else
        {
            Label1.Text = "error in input";
        }
        Label1.Enabled = true;
    }
}
Posted
Updated 29-Aug-13 21:48pm
v3
Comments
[no name] 30-Aug-13 3:38am    
What is the problem..??
Mann Rai 30-Aug-13 3:42am    
i want to use javascript for hide and show usercontrol when i click on linkbutton
Moosavi S.M. 30-Aug-13 3:43am    
where is your javascript code?
Mann Rai 30-Aug-13 3:44am    
i dont know how to use javascript for usercontrol
Mann Rai 30-Aug-13 3:46am    
i want javascript code for hide and show usercontrol on click of Linkbutton

on aspx page, put you user control inside a div -

ASP.NET
<div class="controlParent">
 <uc1:abc id="someId" runat="server" xmlns:uc1="#unknown" />
</div>


On your linkbutton add CssClass -
ASP.NET
<asp:linkbutton id="LinkButton1" runat="server" text="Show/Hide" cssclass="btnHide" xmlns:asp="#unknown" />


In head section of your aspx page, write javascript like -
JavaScript
<!-- Add you jquery.min.js file path here, -->
<script type="text/javascript">
$(document).ready(funcyion(){

   $(".btnHide").click(function(){
      $(".controlParent").toggle();
   });
});

</script>
 
Share this answer
 
Comments
Mann Rai 30-Aug-13 7:45am    
where is jquery.min.js????
Moosavi S.M. 30-Aug-13 8:58am    
google search, download!
Mann Rai 30-Aug-13 8:56am    
plz help me
1) place your user control in a div and give the div an ID so you can
manipulate it using jquery or javascript.

2) hide and show your div using this methods:

$("#divID").animate.hide();
$("#divID").animate.show();

this codes are jquery!

so when the the div hides, then user control hides!
 
Share this answer
 
v10
Comments
Mann Rai 30-Aug-13 4:07am    
i want code for hide and show usercontrol on click of link button
Mann Rai 30-Aug-13 8:52am    
i m not understand what are u saying
 
Share this answer
 
Comments
Mithiten 30-Aug-13 7:34am    
IF GOT ANSWER THEN CLICK ON SOLUTION....
Mann Rai 30-Aug-13 7:54am    
i m not geting the exact answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900