开发者

Posting dynamic data to twitter

开发者 https://www.devze.com 2023-04-01 16:03 出处:网络
I\'m aware that you can post data to twitter <script src=\"http://platform.twitter.com/widgets.js\" type=\"text/javascript\">

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

精彩评论

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