제어가 Fileupload
이고 업로드 버튼을 클릭하면 이미지가 진행률 표시 줄 또는로드 중 GIF 이미지로 표시됩니다. 나는 자바 스크립트를 통해 그것을 시도했지만 그 이미지를 표시 할 수 없습니다. File이 업로드 될 때까지 Image가 표시되기를 원합니다.버튼을 클릭 할 때 진행 표시 줄이 표시되지 않습니다.
이 내 영문 코드 :
<form id="form1" runat="server">
<div class="transbox" id="mainbk" runat="server" style="position:absolute; top:0px; left:0px; width: 100%; height: 100%;" >
<fieldset style="width:51%; margin-left:300px;font-family:'Palatino Linotype';font-size:large">
<legend style="color:white;font-family:'Palatino Linotype'">Upload Video Files</legend>
<asp:FileUpload EnableViewState="true" runat="server" ID="UploadImages" style="background-color:white; position:relative; font-family:'Palatino Linotype'; font-size:medium" Width="500px" AllowMultiple="false"/>
<asp:RequiredFieldValidator ID="reqFile" runat="server" ControlToValidate="UploadImages" ErrorMessage="Select a File" style="color:red;position:absolute"></asp:RequiredFieldValidator><br />
<asp:Label Text="Description:" runat="server" ID="lbldes" style="font-family:'Palatino Linotype';position:absolute; margin-top:10px; font-size:large;color:white" ></asp:Label>
<asp:TextBox id="txtdes" runat="server" TextMode="MultiLine" Height="60px" style="margin-top:10px;margin-left:195px;" Width="300px"></asp:TextBox>
<asp:RequiredFieldValidator ID="txtreq" runat="server" ControlToValidate="txtdes" ErrorMessage="Description Required" style="color:red;position:absolute;margin-top:20px;" ></asp:RequiredFieldValidator><br />
<asp:Button runat="server" ID="uploadedFile" style="position:relative; font-family:'Palatino Linotype'; font-size:medium; width: 112px; height: 29px;" Text="Upload" UseSubmitBehavior="true" OnClick="uploadedFile_Click"/>
<asp:image id="loading_img" runat="server" style="Display:none;position:absolute;margin-top:-20px;margin-left:200px;" src="../Images/Other Images/waiting.gif" />
</fieldset>
</div>
</form>
이 내 자바 스크립트입니다 :
<script type="text/javascript">
$('#uploadedFile').click(function() {
$('#loading_img').show(); // Show image
return true; // Proceed with postback
});
</script>
및 aspx.cs 페이지에서 버튼 uploadedFile이 내 클릭 이벤트.
protected void uploadedFile_Click(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
string fileExt = Path.GetExtension(UploadImages.FileName).ToLower();
if (fileExt == ".flv" || fileExt == ".avi" || fileExt == ".mp4" || fileExt == ".3gp" || fileExt == ".mov" || fileExt == ".wmv" || fileExt == ".mpg" || fileExt == ".asf" || fileExt == ".swf")
{
try
{
filepath = Server.MapPath("~/Videos/" + UploadImages.FileName);
UploadImages.PostedFile.SaveAs(filepath);
vurl=UploadImages.FileName.ToString();
newpath = "Images//Video_Thumbs//" + createvidImage(filepath);
al = txtdes.Text.ToString();
id += 1;
string Insert = "Insert into video (vid,videoname,videourl,vidthumb) values (@id,@alter,@vrl,@IMAGE_PATH)";
SqlCommand cmd = new SqlCommand(Insert, con);
cmd.Parameters.AddWithValue("@IMAGE_PATH", newpath.ToString());
cmd.Parameters.AddWithValue("@id", id);
cmd.Parameters.AddWithValue("@alter", al);
cmd.Parameters.AddWithValue("@vrl", vurl);
try
{
con.Open();
cmd.ExecuteNonQuery();
con.Close();
Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('Video Uploaded!!');", true);
txtdes.Text = "";
}
catch (Exception e1)
{
Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('" + e1.Message.ToString() + "!!');", true);
}
}
catch (Exception ex)
{
Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('" + ex.Message.ToString() + "!!');", true);
}
}
}
}
자바 스크립트 나 C#으로이 작업을 도와주세요.
@ 알렉스 ... 전 페이지를 검사 및 I 버튼 태그의 장소에서이 발견 새로운 WebForm_PostBackOptions (" 사실 uploadedFile ", " ", " ", " " 거짓 거짓)) "ID ="uploadedFile "스타일 ="총수 : 대하여, 폰트 패밀리 '팔라티노 라이노'; 폰트 크기 : 중간 ; 너비 : 112px, 높이 : 29px; "> 실제로 의미하는 바가 있으며 잡히지 않은 참조 오류라고 말하는 오류가 발생합니다. $는 정의되지 않았습니다. –
허. 분명히 내 대답은 태그에 적용되지 않습니다. ID 속성을 얻지 못하면 이름 대신 ID 속성을 선택해야합니다. 그에 따라 내 대답을 편집 할 것입니다. $가 정의되지 않은 경우 jQuery 소스 파일을 페이지에로드하지 않거나 스크립트 블록이 실행되기 전에 해당 파일이로드됩니다. 후자의 경우, 블록을 별도의 .js 파일로 묶고 jQuery 파일 아래의 머리에 넣는 것이 좋습니다. –
Alex
@Alex .. 말하기 유감스럽게 생각하지만 jquery에 대한 많은 지식을 가지고 있지 않기 때문에이 wid u ...를 요청하고 있습니다. jQuery 소스 파일을 작성해야합니다. 이제 내가 한 것은 jScript가 추가 한 스크립트입니다. head 태그 앞에 블록하십시오 ...하지만 여전히 결과는 같습니다 ... ( –