1
Answer

HEEELP - Visual Studio .net - Custom controls

maya_pyr

maya_pyr

21y
1.7k
1
Hi, i created a custom control with visual studio .net, which should read an file. the user who wants to use the control in his project should be able to choose in the properties window the file. Unfortunately I just found out how to write something in there (i already have the property, but as a string), but there should be something like the little button with the 3 point which helps you to select a file and which creates the working string itself, so that the user cant just write anything in. Hope you can help me...
Answers (1)
2
Deepak Verma
NA 1.7k 690.4k 12y

Attachment menudemo.zip

Hi Dinesh,

Refer to this code:

Master Page:

<head runat="server">
  <title></title>
 
  <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
 
  <script src="jquery-1.6.2.js" type="text/javascript"></script>
 
  <script type="text/javascript">
 
  $(document).ready(function () {
  $(".menuLinks").click(function () {
  $(".menuLinks").removeClass("selected");
  });
  });
  </script>
 
  <asp:ContentPlaceHolder ID="head" runat="server">
 
  </asp:ContentPlaceHolder>
 </
head>
 <
body>
  <form id="form1" runat="server">
 
  <div>
 
  <ul class="menu">
 
  <li><a id="link1" class="menuLinks" href="Page1.aspx" runat="server">Link 1</a></li>
 
  <li><a id="link2" class="menuLinks" href="Page2.aspx" runat="server">Link 2</a></li>
 
  <li><a id="link3" class="menuLinks" href="Page3.aspx" runat="server">Link 3</a></li>
 
  </ul>
 
  <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
 
  </asp:ContentPlaceHolder>
 
  </div>
 
  </form>
 </
body>
 

StyleSheet.css :

ul.menu li
 
{
  float: left;
  list-style: none;
 }
 ul.menu
li a
 
{
  text-decoration: none;
  font-family: Tahoma;
  font-size: 20px;
  margin: 0px 10px 0px 0px;
  padding: 3px;
  background-color: Black;
  color: White;
  border-radius: 5px;
 }
 ul.menu li a:hover
 
{
  background-color: Blue !important;
 }
 ul.menu li a.selected
 
{
  background-color: Blue !important;
 } 

Page1.aspx.cs :

 protected void Page_Load(object sender, EventArgs e)
  {
  ((HtmlAnchor)this.Page.Master.FindControl("link1")).Attributes.Add("class", "selected");
  }

Page2.aspx.cs :

 protected void Page_Load(object sender, EventArgs e)
  {
  ((HtmlAnchor)this.Page.Master.FindControl("link2")).Attributes.Add("class", "selected");
  }

Page3.aspx.cs :

 protected void Page_Load(object sender, EventArgs e)
  {
  ((HtmlAnchor)this.Page.Master.FindControl("link3")).Attributes.Add("class", "selected");
  }

Accepted
0
Dinesh Ambaliya
NA 42 59.8k 12y
This will work. Thank you.