F
freshRecruit
Hi,
I am having a problem, and is driving me nuts and my deadline is fast
approaching. Please do help me..
This is a webapplication with a usercontrol which has some buttons for
adding, deleting and updating to a database. When the user clicks the "Add"
button than the information provided is validated against the database. If
the validation succeeds than the information is added to the database. If not
a confirm box is shown and if the user clicks "yes" than the data is added
else the whole operation is suspended.
Here is the code in the usercontrol:
private void provBtnAdd_Clicked(object sender, ImageClickEventArgs e)
{
if (!misc.validateSiteCodes(out error, siteCodeText, startLoginText,
provAcctIDText))
{
string clientID = this.ClientID;
Page.RegisterHiddenField(clientID +"_confirmValue", "0");
string clientConfirm = "<script language=javascript>if (confirm('"
+error +
"?')) { document.getElementById('"+ clientID +
"_confirmValue').value = '1' } <" + "/"+ "script>";
Response.Write(clientConfirm);
}
if (confirmValue == "1")
{
.....// The Addition operation
}
}
The usercontrol also has the following input element:
<input type="hidden" id="confirmValue" name="conformValue" runat="server"
value="0" />
Whenever I click on the "Add" button, the confirm appears in a blank screen
rather than on the existing page and does not do the addition operation
inspite of the user clicking on "yes". The error it is displaying is:
'document.getElementById(...)' is null or not an object
When I investigated the source, it has the element. So I am not sure what is
wrong.
The snippet from the view source:
<script language=javascript>if (confirm('Account ID does not match the site
Number. Do you still want to continue??')) {
document.getElementById('aldpaPnl_confirmValue').value = '1' } </script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
..
..
..
..
..
..
<td colspan="4"><input name="aldpaPnl:confirmValue"
id="aldpaPnl_confirmValue" type="hidden" value="0" /></td>
I have tried using the RegisterStartupScript, but when I use it the confirm
box is shown after the record has been added to the database. I can see the
record being displayed and the confirm box appearing on top of it. The same
with the RegisterClientScriptBlock. Please do help...
Thanks in advance.
I am having a problem, and is driving me nuts and my deadline is fast
approaching. Please do help me..
This is a webapplication with a usercontrol which has some buttons for
adding, deleting and updating to a database. When the user clicks the "Add"
button than the information provided is validated against the database. If
the validation succeeds than the information is added to the database. If not
a confirm box is shown and if the user clicks "yes" than the data is added
else the whole operation is suspended.
Here is the code in the usercontrol:
private void provBtnAdd_Clicked(object sender, ImageClickEventArgs e)
{
if (!misc.validateSiteCodes(out error, siteCodeText, startLoginText,
provAcctIDText))
{
string clientID = this.ClientID;
Page.RegisterHiddenField(clientID +"_confirmValue", "0");
string clientConfirm = "<script language=javascript>if (confirm('"
+error +
"?')) { document.getElementById('"+ clientID +
"_confirmValue').value = '1' } <" + "/"+ "script>";
Response.Write(clientConfirm);
}
if (confirmValue == "1")
{
.....// The Addition operation
}
}
The usercontrol also has the following input element:
<input type="hidden" id="confirmValue" name="conformValue" runat="server"
value="0" />
Whenever I click on the "Add" button, the confirm appears in a blank screen
rather than on the existing page and does not do the addition operation
inspite of the user clicking on "yes". The error it is displaying is:
'document.getElementById(...)' is null or not an object
When I investigated the source, it has the element. So I am not sure what is
wrong.
The snippet from the view source:
<script language=javascript>if (confirm('Account ID does not match the site
Number. Do you still want to continue??')) {
document.getElementById('aldpaPnl_confirmValue').value = '1' } </script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
..
..
..
..
..
..
<td colspan="4"><input name="aldpaPnl:confirmValue"
id="aldpaPnl_confirmValue" type="hidden" value="0" /></td>
I have tried using the RegisterStartupScript, but when I use it the confirm
box is shown after the record has been added to the database. I can see the
record being displayed and the confirm box appearing on top of it. The same
with the RegisterClientScriptBlock. Please do help...
Thanks in advance.