Retrieving information from a user control using jQuery. Visual studio 2010

I am learning web application development using the Microsoft .NET Framework 4. While I am browsing the book, I have a side project at work that I code when I study this material.

This is a simple application that, based on the username, will query the database, dynamically create custom controls based on the number of rows from the database.

A user control is nothing more than an image and a shortcut. However, it does have some member variables: reportName and filePath.

public partial class ReportIcon : System.Web.UI.UserControl
{
    public string reportName { get; set; }
    public string filePath { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {
        ReportNameLabel.Text = this.reportName;
    }
}

These dynamically created icons are created just fine, and the member variables are set according to the database values.

filePath, jQuery onClick. , . , .

$('.report-icons').click(
    function () {
        $(this).siblings().removeClass("selected");
        $(this).addClass("selected");
        alert("Get PDF File");
    }

);

- , jQuery?

+3
3

, JQuery i.e.

<asp:Label runat=server ID="lblFilePath" />

lblFilePath.Text = filePath

JQuery

alert($(#<%=lblFilePath.ClientID%>).text());

.

+1

, , . Crab Bucket , .

HTML

< asp: runat = "server" id = "filePath" /" >

CodeBehind

filePath.value = myReportPath

JQuery

alert ($ ( "# <% = filePath.ClientID% > " ). val());

+1

You can add the data-filepath attribute to the generated HTML element, which can then be read using jquery.

0
source

All Articles