2012-03-31 35 views
0

我想知道是否可以將css添加到處理程序的.aspx文件中的某個元素。在asp.net處理程序中添加css

這是我的處理程序:

Private Sub UploadWholeFile(ByVal context As HttpContext, ByVal statuses As List(Of FilesStatus)) 
     For i As Integer = 0 To context.Request.Files.Count - 1 
      Dim file = context.Request.Files(i) 
      file.SaveAs(ingestPath & Path.GetFileName(file.FileName)) 
      Thread.Sleep(1000) 
      Dim fname = Path.GetFileName(file.FileName) 
      statuses.Add(New FilesStatus With {.thumbnail_url = "Thumbnail.ashx?f=" & fname, .url = "Upload.ashx?f=" & fname, .name = fname, .size = file.ContentLength, .type = "image/png", .delete_url = "Upload.ashx?f=" & fname, .delete_type = "DELETE", .progress = "1.0"}) 
     Next i 
    End Sub 

而且我有一個按鈕,這實際上是在模板文件在我的Default.aspx頁面下方所示:

<script id="template-upload" type="text/x-tmpl"> 
{% for (var i=0, file; file=o.files[i]; i++) { %} 
    <tr class="template-upload fade"> 
    <td><img src="img/paperclip.png"/></td> 
     <td class="imagename"><span>{%=file.name%}</span></td> 
     {% if (file.error) { %} 
      <td class="error" colspan="2"><span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}</td> 
     {% } else if (o.files.valid && !i) { %} 

      <td class="start" style="visibility:hidden">{% if (!o.options.autoUpload) { %} 
       <button class="btn btn-primary"> 
        <i class="icon-upload icon-white"></i> 
        <span>{%=locale.fileupload.start%}</span> 
       </button> 
      {% } %}</td> 
     {% } else { %} 
      <td colspan="2"></td> 
     {% } %} 
     <td class="cancel">{% if (!i) { %} 
      <button class="btn btn-warning"> 
       <i class="icon-ban-circle icon-white"></i> 
      </button> 
     {% } %}</td> 
    </tr> 
{% } %} 
</script> 

現在我想改變按鈕成像。 那麼我該如何從處理程序中做到這一點?

如果我點擊下面的按鈕,我需要改變的圖標btn-warning

<button type="submit" class="btn btn-primary start"> 
        <i class="icon-upload icon-white"></i> 
        <span>Start upload</span> 
</button> 

回答

2

如果更改按鈕圖像客戶端,當用戶點擊它,它會更容易些。 (它看起來像真的是你以後在做什麼)

<button class="btn btn-primary" onclick="changeToImage();"> 

function changeToImage() 
{ 
    $('.btn-warning').replaceWith('<img src="/wherever.jpg"/>'); 
} 

Swap button for image (Jquery)

+0

@ msigman,首先感謝您reply.May是你right.But我有一個按鈕,兩個buttons.On點擊我需要改變其他。所以在這種情況下我該如何修改。 – coder 2012-03-31 17:57:15

+0

我已經更新了我的答案,而不是替換btn-warning按鈕。 – msigman 2012-03-31 18:00:22

+0

@ msigman-謝謝你的工作正是我需要的。歡呼:) – coder 2012-03-31 18:08:26