Question

Is it possible to set the value of data-id from the textbox with the id of txtPublicProfileId?

.aspx:

 <asp:TextBox ID="txtPublicProfileId" runat="server"></asp:TextBox>

 <script src="//platform.linkedin.com/in.js" type="text/javascript"></script>
 <script type="IN/MemberProfile" data-format="inline" data-id=""></script>

Button-click event will assign the value of the textbox to data-id attribute.

Was it helpful?

Solution

In the markup add a literal control where you want the script:

 <asp:TextBox ID="txtPublicProfileId" runat="server"></asp:TextBox>
 <script src="//platform.linkedin.com/in.js" type="text/javascript"></script>
 <asp:Literal ID="ltlMyScript" runat="server" Text='<script type="IN/MemberProfile" data-format="inline" data-id="" ></script>' ></asp:Literal>

And in code add the script with the id to the literal:

protected void Button1_Click(object sender, EventArgs e)
{
    ltlMyScript.Text = "<script type=\"IN/MemberProfile\" data-format=\"inline\" data-id=\"" + txtPublicProfileId.Text + "\"></script>";
}

And here's how it is rendered with the id:

enter image description here

OTHER TIPS

What id do you need? ClientID? Server ID?

txtPublicProfileId.Attributes.Add("data-id", txtPublicProfileId.ClientId)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top