I have a user control:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Autocomplite.ascx.cs" Inherits="Application.Controls.Autocomplite" %>
<script type="text/javascript" src="../Scripts/Autocomplite.js"></script>
<img alt="" src="Images/Common/transfer1.png" style="cursor:pointer;" onclick='SelectInfo(this); return false;' />
with properties:
public partial class Autocomplite : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
private string tableDataSourse;
public string TableDataSourse
{
get { return tableDataSourse; }
set { tableDataSourse = value; }
}
private string positionId;
public string PositionId
{
get { return positionId; }
set { positionId = value; }
}
}
I register this control on page and run it like this:
<%@ Register TagPrefix="apress" TagName="Autocomplite" Src="~/Controls/Autocomplite.ascx" %>
...
<apress:Autocomplite ID="AutoTextBox1" runat="server" TableDataSourse="DataSet" PositionId="NewOrderArticleCode" />
On Autocomplite.js (javascript client side) in SelectInfo function I try to get this properties:
function SelectInfo(obj) {
if (obj != null) {
// expected that obj have this properties
}
}
You should render values of those properties into html elements or attributes, (such as an input element or custom-attributes of an image element). then you can get those values through client-side code.
rendering control-level properties into html code :
access to rendered attribute :