Reputation: 63
in my HTML, I have a fileUpload button where you can choose a file to upload a file and then once you click pbcUploadBtn, it goes through validation in Validation.CheckWellFormed(...)
. The validation method returns an empty string if the file is fine or a string with the first error in the file otherwise. How can I have this display on my page using jQuery or js, etc.?
<div class="upload">
<asp:FileUpload ID="fileUpload" class="btn" runat="server" />
<asp:Button ID="pbcUploadBtn" class="btn btn-primary" runat="server" Text="Upload" onclick="uploadBtnClick" />
</div>
protected void uploadBtnClick(object sender, EventArgs e)
{
if (this.fileUpload.HasFile)
{
// file gets uploaded to szSaveToPath
Validation.CheckWellFormed(szSaveToPath);
//do things
}
}
Upvotes: 0
Views: 57
Reputation: 56
You don't need to use js in this case. You can add a label and change it's text property:
<div class="upload">
<asp:FileUpload ID="fileUpload" class="btn" runat="server" />
<asp:Button ID="pbcUploadBtn" class="btn btn-primary" runat="server" Text="Upload" onclick="uploadBtnClick" />
<asp:Label runat="server" ID="lblStatus"></asp:Label>
protected void uploadBtnClick(object sender, EventArgs e)
{
if (this.fileUpload.HasFile)
{
// file gets uploaded to szSaveToPath
lblStatus.Text = Validation.CheckWellFormed(szSaveToPath);
//do things
}
}
Upvotes: 4