0
当我将新控件添加到我的web应用程序时,javascript不会触发。我已经尝试了很多解决方案,但都没有工作。具体来说,AJAX Control Toolkit中的accordion/accordion窗格不会向上/向下滑动。此外Obout的FileUploadProgress控件使用不会触发的javascript函数。如果我打开一个新的Web应用程序项目并尝试所有这些,它就可以正常工作。我的项目很大,所以我无法从头开始。有人能告诉我什么可能是我的项目有问题吗?我没有错误。 JavaScript根本不会触发。请帮忙。我正在使用asp.net c#。AJAX javascript not firing asp.net c#
编辑:
这里是文件上传进度控制的代码。我确实有警报声明,但他们没有开火。
<script type="text/JavaScript">
function Clear() {
alert("here1");
document.getElementById("<%= uploadedFiles.ClientID %>").innerHTML = "";
}
function ClearedFiles(fileNames) {
alert("here2");
alert("Cleared files with bad extensions:\n\n" + fileNames);
}
function Rejected(fileName, size, maxSize) {
alert("here3");
alert("File " + fileName + " is rejected \nIts size (" + size + " bytes) exceeds " + maxSize + " bytes");
}
</script>
<input type="file" name="myFile1" runat="server"/><br/>
<input type="file" name="myFile2" runat="server"/><br/>
<input type="file" name="myFile3" runat="server"/><br/>
<input type="submit" value="submit" name="mySubmit" /><br/>
<br/>
<fup:FileUploadProgress ID="FileUploadProgress1"
OnClientProgressStopped = "function(){alert('Files are uploaded to server');}"
OnClientProgressStarted = "Clear"
ShowUploadedFiles = "true"
OnClientFileRejected = "Rejected"
OnClientFileCleared = "ClearedFiles"
runat = "server"
>
<AllowedFileFormats>
<fup:Format Ext="gif" MaxByteSize="10240"/>
<fup:Format Ext="jpg" MaxByteSize="10240"/>
<fup:Format Ext="jpeg" MaxByteSize="10240"/>
<fup:Format Ext="png" MaxByteSize="10240"/>
</AllowedFileFormats>
</fup:FileUploadProgress>
<asp:Label runat="server" id="uploadedFiles" Text="" />
而这里的代码隐藏它:
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
HttpFileCollection files = Page.Request.Files;
uploadedFiles.Text = "";
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile file = files[i];
if (file.FileName.Length > 0)
{
if (uploadedFiles.Text.Length == 0)
uploadedFiles.Text += "<b>Successfully uploaded files: </b><table border=0 cellspacing=0>";
uploadedFiles.Text += "<tr><td class='option2'>" + file.FileName.Substring(file.FileName.LastIndexOf("\\") + 1) + "</td><td style='font:11px Verdana;'> " + file.ContentLength.ToString() + " bytes</td></tr>";
}
}
if (uploadedFiles.Text.Length == 0)
uploadedFiles.Text = "no files";
else
uploadedFiles.Text += "</table>";
}
}
在此先感谢!
放置一些警报消息,并查看并在您的问题中放置一些代码。所以我们可以看到你是如何调用javascript函数,并会告诉你的错误 –
你的JavaScript和你需要加载在客户端上的JavaScript库吗? – Barka
“添加新控件”是什么意思?用户控件添加到项目?从刚刚添加的Control继承的类? – sq33G