|
hai,
i want to show an alert message or something when my control goes to catch block in the try catch...
please help me..
alex.
|
|
|
|
|
Register your javascript if that statement is true at server
i.e in page load
if(check the condition)
ClientScript.RegisterStartupScript(this.GetType(), "AnyKey", "alert('dont do this ?');", true);
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Hai,
Thanks for your reply...
But my case is that i want to show that error message in catch block...in the try catch..
if something is happened in catch block i want to show a alert message....
The above code is not working ..in my case..
please help me...
alex.
|
|
|
|
|
No doubt it should work see
this
try<br />
{<br />
FileInfo fi = new FileInfo("");<br />
fi.MoveTo("sandeep.txt");<br />
if (fi.Name == "sometx")<br />
{ <br />
}<br />
}<br />
catch(Exception ex)<br />
{ <br />
ClientScript.RegisterStartupScript(this.GetType(), "AnyKey23", "alert('Frist time dont do this ?');", true);<br />
}
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Hi,
Once gain thx,,,,
but i am using asp.net ajax ....all my controls are place in asp.updatepanel...
what i give is
catch (Exception ex)
{
ClientScript.RegisterStartupScript(this.GetType(), "AnyKey", "alert('dont do this ?');");
//Response.Write("mg='kkk'");
//(this.Master as View_pages_MasterPage).SetError("hihihji");
}
but it's not working...
help me..
alex.
|
|
|
|
|
see source file of your page and check the alert script is present or not ?
What the problem are you facing ?
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
hai,
The only problem is that alert is not coming the control is go through the code in catch and executing the script code also but alert is not coming....
alex.
my code block is give below....
protected void ChangeStatus(object sender, EventArgs e)
{
try
{
DamageReportHistory damageReportHistory = new DamageReportHistory();
DamageReportHistoryBO damageReportHistoryBO = new DamageReportHistoryBO();
DamageReportBO damageBO = new DamageReportBO();
DamageReportStatus damageReportStatus = new DamageReportStatus();
// we need the damage report again (because the hibernate session was ended at this point)
//DamageReport = (DamageReport)damageBO.GetObjectByID(Id);
DamageReport = new DamageReport();
DamageReport.DamageOldStatus = DamageReport.DamageStatus;
DamageReport.DamageStatus = drpStatus.SelectedItem.Text;
User user = CommonFunctions.GetCurrentUser();
damageBO.UpdateStatus(DamageReport, user);
//The section below is for updating damage report history table.
damageReportHistory.HistoryDetails = DamageReport.Description;
damageReportHistory.CreatedDate = DateTime.Now;
damageReportHistory.Comments = txtComments.Text;
damageReportHistory.HistoryXML = DamageReport.DamageReportXML;
damageReportHistory.CreatedUser = CommonFunctions.GetCurrentUser().UserName;
damageReportHistory.RelatedDamageReport = DamageReport;
damageReportStatus.Id = int.Parse(drpStatus.SelectedValue.ToString());
damageReportHistory.CurrentStatus = damageReportStatus;
damageReportHistoryBO.Save(damageReportHistory);
//Response.Redirect("DamageReportOverview.aspx");
}
catch (Exception ex)
{
ClientScript.RegisterStartupScript(this.GetType(), "AnyKey", "alert('dont do this ?');",true);
//Response.Write("mg='kkk'");
//(this.Master as View_pages_MasterPage).SetError("hihihji");
}
}
hoep you understand my problem again i remember you my controls are placed in
<asp:updatepanel id="UpdatePanel1" runat="server">
alex.
|
|
|
|
|
Malayil alex wrote: ClientScript.RegisterStartupScript(this.GetType(), "AnyKey", "alert('dont do this ?');",true);
here is the problem don't pass fourth bool parameter if you are saying passing script tag in third parameter
try this
ClientScript.RegisterStartupScript(this.GetType(), "AnyKey", "alert('dont do this ?');");
or
ClientScript.RegisterStartupScript(this.GetType(), "AnyKey", "alert('dont do this ?');",true);
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Hi,
I tried both...no alert is coming...
alex.
|
|
|
|
|
try this code in catch block
Response.Write("<script>alert('dont do this');</script>");
Best Regard
Pathan
---------------------------------------------------
|
|
|
|
|
hai,
That also i tried ,,but no way..
alex.
|
|
|
|
|
have you tried in catch block?
check out it in page load event and tell me.
Best Regard
Pathan
---------------------------------------------------
|
|
|
|
|
Hi,
Yes it's work when i put in page load ,but once i give that code in the catch block some system alert error messages are coming ..
alex.
|
|
|
|
|
System Error Message?
---------------------------------------------------
|
|
|
|
|
hai,
yes system handling error.like exception ......shows in an alert box not the thing that we want..
alex
|
|
|
|
|
Apart from registering the script are you doing any thing else ?
means logging the error something like that ?
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
|
If you are using updatepanels I don't think the script will get registered with the script manager on postback as the page is already rendered.
What you want to try is register the script as a function function ShowMyError( message) {...} on PageLoad, and then, in your Exception handler, call the function
<br />
ClientScript.RegisterStartupScript(this.GetType(), "AnyKey", "ShowMyError('dont do this ?');",true); <br />
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"I haven't spoken to my wife now for 48 hours. I don't like to interrupt her.
|
|
|
|
|
hi,
what i did ,
in the page load
ClientScript.RegisterStartupScript(this.GetType(), "AnyKey", "function show(msg){ alert(msg);}");
and in the catch block\
ClientScript.RegisterStartupScript(this.GetType(), "AnyKey", "show('dont do this ?');", true);
it's not work
alex
|
|
|
|
|
Guessing a little here but try using the ScriptManager, as this lets you specify a control..
<br />
ScriptManager.RegisterStartupScript(yourUpdatePanel, page.GetType() , "AnyKey", "show('dont do this ?');", true); <br />
I just found this[^] as well. It might help. Make sure you post the solution - I need someting similar, but can't get to dev box at the moment!
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"I haven't spoken to my wife now for 48 hours. I don't like to interrupt her.
|
|
|
|
|
i am developing application in ASP.Net with C#. i am using button for FileOpenDialog to browse any image from hard drive as follows
openFileDialog1.ShowDialog();
string s = openFileDialog1.FileName;
textBox6.Text = s;
problem is:
i want the browsed image to be copied in local hosti.e,""C:\\Inetpub\\wwwroot\\15 WebSite\\images\\1.jpg"
i have the follwing idea in mind
File.Copy("C:\\Inetpub\\wwwroot\\15 WebSite\\images\\1.jpg", "C:\\Inetpub\\wwwroot\\15 WebSite\\images\\xyz.jpg");
or
File.Copy(s.Substring(13,s.Length-13), "C:\\Inetpub\\wwwroot\\15 WebSite\\images\\xyz.jpg");
but i dont want to existing image to be overwrite, i want all images to ve saved in local host
can anyone sugesst me what to do?
|
|
|
|
|
But what if the user(client) wants to copy a file from its machine to server
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
but my requirement is that in Windows application user is browsing image and clicking the "save" button to save it in database, i have to lauch the same image in website to i want the image to be copied in local host, can u suggest any solution for that
|
|
|
|
|
mavii wrote: my requirement is that in Windows application user
But in your first query you posted that you are developing asp.net application . i don't have much idea about that but post your queries in right forum
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
mavii wrote: but my requirement is that in Windows application user is browsing image and clicking the "save" button to save it in database,
Is images are stored in database ?
mavii wrote: i have to lauch the same image in website to i want the image to be copied in local host, can u suggest any solution for that
Still I am not getting what you mean by this.
1 - Why user is browsing image from an windows application
2 - From where the user comes ? If the user is coming from another system, how can you copy the file to your local drive ?
Please make your question more clear
|
|
|
|