开发者

Posting dynamic data to twitter

I'm aware that you can post data to twitter

<script src="http://platform.twitter.com/widgets.js" type="text/javascript">
    </script>
<div>
<a href="http://twitter.com/share" class="twitter-share-button"
    data-url="http://bit.ly/twitter-api-announce"
    data-counturl="http://groups.google.com/group/twitter-api-announce"
    data-text="Checking out this page about Tweet Buttons"
</div>

But is there a way to populate the data-text dynamically. For example set the value depending on an asp:Label t开发者_运维百科ext.?


You can do the following in your ASPX page:

<script src="http://platform.twitter.com/widgets.js" type="text/javascript">
    </script>
<div>
<a href="http://twitter.com/share" class="twitter-share-button"
    data-url="http://bit.ly/twitter-api-announce"
    data-counturl="http://groups.google.com/group/twitter-api-announce"
    data-text='<%= "Insert your variable here" %>'
</div>

Note the "Insert your variable here" string; replace that with a variable that will produce a string and that will be rendered to your page.


Since this is a static piece of code but you probably using it in an aspx application, of course you must be able to change the value dynamically. It's almost the same as filling a label or a textbox.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜