I want to display dynamic ID generated while inserting the record in the database in alert.
So I implemented the below mentioned code for my use.
ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Request has been created for Sap ID ='" + ObjIPColoFields.SAP_ID + " with Request No: '" + strReturnId + "'); window.location ='IpColoDefault.aspx';", true);
But nothing is happening, but when I removed the parameters it works fine. How to make it work with parameters
You have some extra apos that is causing the
alertto be broken. Assuming thatSAP_IDis 123 andstrReturnIdis 456, the script you build is:There are two extra apos here, one after
=and one before456. Remove them and you have a better chance of actually seeing an alert. What you want is probably:Of course the end result also depends on the actual value of the
SAP_IDandstrReturnId. If they are strings, you need to make sure that they don't contain apos or quotes, or you need to properly escape those chars.Try this: