Click here to Skip to main content
15,888,610 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Open Byte Array and Save from Browser Pin
Nisha Agrawal1-Oct-09 20:27
Nisha Agrawal1-Oct-09 20:27 
QuestionRe: Open Byte Array and Save from Browser Pin
Danang Prakoso5-Oct-09 16:21
Danang Prakoso5-Oct-09 16:21 
QuestionRe: Open Byte Array and Save from Browser Pin
Danang Prakoso1-Oct-09 17:01
Danang Prakoso1-Oct-09 17:01 
Question[Message Deleted] Pin
11Developer30-Sep-09 19:23
11Developer30-Sep-09 19:23 
AnswerRe: Captcha Image on HTML by ASP code Pin
Abhijit Jana30-Sep-09 20:09
professionalAbhijit Jana30-Sep-09 20:09 
AnswerRe: Captcha Image on HTML by ASP code Pin
sashidhar30-Sep-09 20:16
sashidhar30-Sep-09 20:16 
AnswerRe: [Message Deleted] Pin
Abhijit Jana30-Sep-09 20:47
professionalAbhijit Jana30-Sep-09 20:47 
QuestionSetting value of HiddentField server side while using UpdatePanel Pin
Ramon Enachescu30-Sep-09 16:34
Ramon Enachescu30-Sep-09 16:34 
Hi all!

I looked and I searched and I came out empty... I am trying to do what should be a straightfoward task: update the value of a HiddenField and use that client side in a script. Here is the scenario:

- User goes to a page that has a Cancel button
- If the user changes anything at all on the page (adds items to a grid, changes textfields, etc.) I want the Cancel button to return a confirmation ("Are you sure you want to continue? Your changes will be lost.")

The elements on the page (textboxes, grid, etc) are all in an AJAX UpdatePanel. The Cancel button calls a javascript function which checks the value of a HiddenField to figure out whether to display the confirmation or not.

So, here's what I have so far:

My Cancel button:
<asp:ImageButton ImageUrl="~/images/ButtonCancel.png" style="float:right" OnClientClick="return RequestMessage();"
                            ID="btnCancel" CssClass="button" runat="server" OnClick="btnCancel_Click" 
                            CausesValidation="False" />


The javascript function behind the OnClick event:
<script type="text/javascript">
      function RequestMessage()
      {
        if($get("ctl00_BodyPH_ConfirmationMsg").value=="true")
        {
            return confirm('Are you sure you want to continue? Your changes will be lost.')
        }
        else
            return true;
      }
    </script>


The HiddenField is defined inside the UpdatePanel:
<asp:HiddenField runat="server" ID="ConfirmationMsg" Value="true" />

And it is registered in the protected override void Render(HtmlTextWriter writer) event:
ScriptManager.RegisterHiddenField(this.Page, ConfirmationMsg.ClientID, "false");


When I look at the code generated on the client side the HiddenField seems to be correctly registered as such:
<input type="hidden" name="ctl00_BodyPH_ConfirmationMsg" id="ctl00_BodyPH_ConfirmationMsg" value="false" />


So everything is good so far. The problem comes when I try to change the value of the HiddenField from various events, such as a simple TextBox_TextChanged event:
protected void txtCustomerID_TextChanged(object sender, EventArgs e)
{
    ConfirmationMsg.Value = "true";
    loadCustomerInfo(false);
}


The event fires but the value for the HiddenField never changes client side, it always stays "false". How can I updated this value throughout the code so that the confirmation will show correctly?? Or am I going about this the wrong way? Is there a better way of achieving the same task another way?

Thanks very much for any insight into this!
AnswerRe: Setting value of HiddentField server side while using UpdatePanel Pin
N a v a n e e t h30-Sep-09 17:42
N a v a n e e t h30-Sep-09 17:42 
GeneralRe: Setting value of HiddentField server side while using UpdatePanel Pin
Ramon Enachescu30-Sep-09 18:00
Ramon Enachescu30-Sep-09 18:00 
Questionwrap string in a gridview column Pin
eirikr130-Sep-09 13:10
eirikr130-Sep-09 13:10 
AnswerRe: wrap string in a gridview column Pin
Kannan Ar30-Sep-09 15:44
professionalKannan Ar30-Sep-09 15:44 
QuestionCustom Composite Server Control Children not visible to the designer Pin
SlingBlade30-Sep-09 12:23
SlingBlade30-Sep-09 12:23 
AnswerRe: Custom Composite Server Control Children not visible to the designer Pin
Christian Graus30-Sep-09 13:03
protectorChristian Graus30-Sep-09 13:03 
GeneralRe: Custom Composite Server Control Children not visible to the designer Pin
SlingBlade30-Sep-09 13:12
SlingBlade30-Sep-09 13:12 
AnswerRe: Custom Composite Server Control Children not visible to the designer Pin
N a v a n e e t h30-Sep-09 17:28
N a v a n e e t h30-Sep-09 17:28 
GeneralRe: Custom Composite Server Control Children not visible to the designer Pin
SlingBlade30-Sep-09 17:50
SlingBlade30-Sep-09 17:50 
GeneralRe: Custom Composite Server Control Children not visible to the designer Pin
N a v a n e e t h30-Sep-09 17:59
N a v a n e e t h30-Sep-09 17:59 
GeneralRe: Custom Composite Server Control Children not visible to the designer Pin
SlingBlade30-Sep-09 18:02
SlingBlade30-Sep-09 18:02 
QuestionFileUpload doesnt upload Pin
Wouter Coinless30-Sep-09 10:35
Wouter Coinless30-Sep-09 10:35 
AnswerRe: FileUpload doesnt upload Pin
Abhishek Sur30-Sep-09 10:48
professionalAbhishek Sur30-Sep-09 10:48 
GeneralRe: FileUpload doesnt upload Pin
Wouter Coinless30-Sep-09 11:08
Wouter Coinless30-Sep-09 11:08 
GeneralRe: FileUpload doesnt upload Pin
Abhishek Sur30-Sep-09 11:44
professionalAbhishek Sur30-Sep-09 11:44 
GeneralRe: FileUpload doesnt upload Pin
Wouter Coinless30-Sep-09 22:04
Wouter Coinless30-Sep-09 22:04 
GeneralRe: FileUpload doesnt upload Pin
Abhishek Sur30-Sep-09 22:26
professionalAbhishek Sur30-Sep-09 22:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.