简体   繁体   English

C#语法和创建UUID

[英]C# syntax and creating UUIDs

Okay, .NET newbie here, so bear with me. 好的,.NET新手在这里,请多多包涵。 I'm trying to create a unique identifier for the selector that the JS function is triggering. 我正在尝试为JS函数触发的选择器创建唯一标识符。 This has to be done in C#, so I'm using the UUID method to get this done. 这必须在C#中完成,因此我正在使用UUID方法来完成此操作。 However, it's not working and I'm thinking that my syntax is probably incorrect or I need some Out.WriteLines around the javascript elements. 但是,它不起作用,我认为我的语法可能不正确,或者我需要在javascript元素周围添加一些Out.WriteLines。 Can someone help me? 有人能帮我吗? I'm stumped and haven't got a clue where I went wrong. 我很困惑,也不清楚我哪里出错了。 (Either way, it's not outputting the value on the end of #jquery_jplayer_(value).) I just need pointed in the right direction, or maybe a tutorial. (无论哪种方式,都不会在#jquery_jplayer_(value)的末尾输出值。)我只需要指出正确的方向,或者是教程。 Thanks in advance. 提前致谢。

 case "video":
    string thumbnailImage = "";
    if (contentBlock["video_thumbnail"] != "") {
        thumbnailImage = contentBlock["video_thumbnail"];
    }

    string uuid = "videoPlayerIdentifier"; 
    %>
        <div class="videoPlayer">
            <a class="video" href="#<%=contentBlock["video_id"]%>"><img height="94" width="172" alt="Play video" src="<%=thumbnailImage%>" style="float:right;"/></a> 
            <a id="<%=contentBlock["video_id"]%>anchor" name="<%=contentBlock["video_id"]%>anchor"></a>
            <%=contentBlock["video_caption"]%>
            <ul class="square"> 
                <li><a class="video" href="#<%=contentBlock["video_id"]%>">Play Video</a></li>
            </ul>        
        </div>
        <script type="text/javascript">
            $(document).ready(function () {

                $("#jquery_jplayer_<%=videoPlayerIdentifier%>").jPlayer({
                    ready: function () {
                        $(this).jPlayer("setMedia", {
                            mp4: "<%=contentBlock["video_mp4"]%>",
                            webm: "<%=contentBlock["video_webm"]%>",
                            ogv: "<%=contentBlock["video_ogv"]%>",
                            poster: "<%=contentBlock["video_still"]%>"
                        });
                    },
                    swfPath: "/video/",
                    supplied: "mp4, webm, ogv"
                });
            });
        </script>

As Mathew points out, I think you've mixed up your variable name with it's value. 正如Mathew指出的那样,我认为您已经将变量名与其值混合了。 If you want your variable to be a unique identifier though, you could replace your initialization with 如果您希望变量是唯一标识符,则可以将初始化替换为

string uuid = System.Guid.NewGuid().ToString();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM