Click here to Skip to main content
16,016,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<asp:FileUpload ID="FileUpload1" runat="server" CssClass="style3" />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator20" runat="server" ControlToValidate="FileUpload1"
                        ErrorMessage="*" ForeColor="#FF6600" ValidationGroup="btnUpload"></asp:RequiredFieldValidator>

C#

Posted
Comments
[no name] 3-Dec-14 6:56am    
What's the problem?, put error or problem scenario here
CP_vicky 3-Dec-14 7:00am    
If i submit Upload button without any data given it is showing like System.IO.DirectoryNotFoundException: Could not find a part of the path.

but i need * (ErrorMessage="*")
DamithSL 3-Dec-14 7:02am    
you haven't add upload button related aspx page code and c# code on your upload button click event. please update the question with the code and full error message
CP_vicky 3-Dec-14 7:09am    
protected void btnUpload_Click(object sender, EventArgs e)
{

uploadDocument();
string date = DateTime.Now.ToString("dd-MM-yyyy");
string imageid = DAL.getRunningID("4");
sqlstr = "insert into Images(ImageID,URL,DateTime)values(" + imageid + ",'" + path + "','" + date + "')";
string sqlUpdate = "update Fms_Autonumber set RNo='" + imageid + "' where RCode='4'";
List<string> ids = new List<string>();
ids.Add(sqlstr);
ids.Add(sqlUpdate);
int j = DAL.sqlTransaction(ids);
if (j > 0)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Successfully Inserted", "alert('Image Uploaded Successfully..!')", true);
}
mltImageurl.Text = strFileName1;
}


<asp:Button ID="btnUpload" runat="server" Text="Upload" CssClass="style3" Height="26px"
Width="100px" OnClick="btnUpload_Click" />
DamithSL 3-Dec-14 7:17am    
do you have updatepanel?

1 solution

Make sure ValidationGroup="btnUpload" in your button
 
Share this answer
 
Comments
CP_vicky 3-Dec-14 7:12am    
Thank you. got it
King Fisher 3-Dec-14 7:29am    
Solved?
CP_vicky 3-Dec-14 7:30am    
ya solved
King Fisher 3-Dec-14 7:31am    
post your Solution if you solved yourself
CP_vicky 3-Dec-14 7:36am    
I solved using your solution.

<asp:Button ID="btnUpload" runat="server" Text="Upload" CssClass="style3" Height="26px"
Width="100px" OnClick="btnUpload_Click" ValidationGroup="btnUpload"/>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900