IT_info
IT_info

Reputation: 727

get element in javascript

I have a Repeater which i am bounding some data to it. Now my problem is how i can refer to the data I have in my label in the repeater from the javascript. My code is the following;

CODEBEHIND

protected void Page_Load(object sender, EventArgs e)
 {

 // bool boolfound = false;
 string connstring = String.Format("Server=localhost; Port=5432; User Id=postgres; Password=database; Database=valletta;");

 using (NpgsqlConnection conn = new NpgsqlConnection(connstring))
 {
  try
   {
    conn.Open();

    NpgsqlCommand cmd = new NpgsqlCommand("select get_points('temp_intersect', 'point','id',17339)", conn);
    NpgsqlDataReader dr = cmd.ExecuteReader();

    currentpoint.DataSource = dr;
    currentpoint.DataBind();

   }
   catch (Exception)
   {
    ClientScript.RegisterStartupScript(this.GetType(), "", "$(document).ready(function(){alert('problem with connection')});", true);
   }
 }

}

ASP

<asp:Repeater ID="currentpoint" runat="server">
   <ItemTemplate>
     <div>
       <asp:Label ID="hiddenlabel" runat="server" Text='<%# Eval("get_points")%>' Visible="false">
       </asp:Label>
      </div>
    </ItemTemplate>
 </asp:Repeater>

Upvotes: 2

Views: 748

Answers (2)

Ryan
Ryan

Reputation: 635

Try this one:

document.getElementById('<%=currentpoint.FindControl("hiddenlabel").ClientID%>')

Upvotes: 1

Greg
Greg

Reputation: 1719

You can change the ClientIDMode to Predictable or static, works well with javascript.

Read this post

Upvotes: 3

Related Questions