Connecting Tech Pros Worldwide Help | Site Map

Javascript Server-side Action Questions..

den 2005
Guest
 
Posts: n/a
#1: Oct 6 '06
Hi everybody,

Question 1: How do you set the values from server-side to a client-side
control or how do you execute a javascript function without a button click
event?
Question 2: How do you get response from a Confirm() popup window to
uncheck all server-side checkboxes placed in a panle of a web user control?

I am using ASP.Net 2.0, Thanks. Need info...

Question 1:
Expand|Select|Wrap|Line Numbers
  1. <td id="mam" height="180">
  2. <iframe id="NewsBody_rich" src="includes/MsgBody.htm"
  3. width="100%" height="100%"
  4. onblur="fillTxt()" style="font-family:
  5. Arial"></iframe>
  6. </td>
  7.  
  8. //Javascript function to be executed
  9. function setTxt(szText)
  10. {
  11. var State = new Object()
  12. var aa;
  13. NewsBody_rich.document.body.innerHTML = szText;
  14. }
  15.  
Question 2:
Expand|Select|Wrap|Line Numbers
  1. UserControl mentioned
  2. <%@ Control Language="C#" AutoEventWireup="true"
  3. CodeFile="AlbumDetailList.ascx.cs" Inherits="usercontrols_AlbumDetailList" %>
  4. <asp:Panel ID="pnlMain" runat="server" Height="600px" Width="824px">
  5. <table id="tblMain" width="824" border="0">
  6. ....
  7. <tr>
  8. <td>
  9. <asp:Panel ID="pnlPhotos" runat="server" Height="100px"
  10. Width="824px">
  11. </asp:Panel>
  12. </td>
  13. </tr>
  14. ...
  15. </table>
  16. </asp:Panel>
  17.  
  18. Inside MasterPage:
  19.  
  20. <script language="javascript" type="text/javascript">
  21. .....
  22. function ConfirmDelete(szText)
  23. {
  24. var confirmed = confirm("Are you sure you want to delete the " +
  25. szText + "?");
  26.  
  27. if(confirmed)
  28. return true;
  29. else
  30. return false;
  31. }
  32. .....
  33. </script>
  34.  
  35. //Add attributes to delete buttons
  36. private void InitializeButtonAttributes()
  37. {
  38. btnDelete1.Attributes.Add("onclick", "javascript:return
  39. ConfirmDelete('Image/s')");
  40. btnDelete2.Attributes.Add("onclick", "javascript:return
  41. ConfirmDelete('Image/s')");
  42. }
  43.  
  44. I need to execute this method:
  45. //Remove Checked in CheckBox
  46. private void ReInitializeCheckbox()
  47. {
  48. foreach (Control ctrl in myPanel.Controls)
  49. {
  50. ....
  51. CheckBox chkPhoto = (CheckBox)ctrl.FindControl(ctrl.ID);
  52.  
  53. if (chkPhoto.Checked)
  54. chkPhoto.Checked = false;
  55. ...
  56. }
  57. }
  58.  
  59. // As suggested in another forum, I tried this but when cancel is click,
  60. it executed
  61. //the GetSelectedPhotosForDeletion() method
  62. function ConfirmDelete(szText)
  63. {
  64. var confirmed = confirm("Are you sure you want to delete the " +
  65. szText + "?");
  66.  
  67. if(confirmed)
  68. return true;
  69. else
  70. {
  71.  
  72. var allInputs = Form1.getElementsByTagName('INPUT'); //check all
  73. input boxes
  74.  
  75. for ( var i=0; i<allInputs.length; i++ )
  76. {
  77. if ( allInputs.type == 'checkbox'
  78. )
  79. {
  80. if ( allInputs.checked)
  81. allInputs.checked =
  82. false;
  83. }
  84. }
  85. //do the same for 'select' controls and
  86. radio buttons
  87. return false;
  88. }
  89. }
  90.  
  91.  
  92. //This gets executed
  93. protected void btnDelete_Click(object sender, EventArgs e)
  94. {
  95. GetSelectedPhotosForDeletion();//even clicking cancel in
  96. confirm this gets executed..
  97. }
  98.  
  99.  
Thanks in advanced..

den2005

--
MCP Year 2005, Philippines
Baski
Guest
 
Posts: n/a
#2: Oct 6 '06

re: Javascript Server-side Action Questions..


>
Quote:
Question 1: How do you set the values from server-side to a client-side
control or how do you execute a javascript function without a button click
event?
What ever asp.net control post back to your server even handler add
the following code

this.Page.RegisterStartupScript("StartupScript","< script>YourJavascriptFunctionName()</script>");



when page post back this method will be called on page load, if needed , you
can also pass value to your javascripr function from server side.

like below

this.Page.RegisterStartupScript("StartupScript","< script>YourJavascriptFunctionName('param1',
'param2')</script>");
Quote:
Question 2: How do you get response from a Confirm() popup window to
uncheck all server-side checkboxes placed in a panle of a web user
control?
since you are return true or false in your confirmation , your delete button
event handler will be called back upon true,
there you can write your checkbox selection logic.


"den 2005" <den2005@discussions.microsoft.comwrote in message
news:84001420-548B-437A-B876-CD07C8778C29@microsoft.com...
Quote:
Hi everybody,
>
Question 1: How do you set the values from server-side to a client-side
control or how do you execute a javascript function without a button click
event?
Question 2: How do you get response from a Confirm() popup window to
uncheck all server-side checkboxes placed in a panle of a web user
control?
>
I am using ASP.Net 2.0, Thanks. Need info...
>
Question 1:
Expand|Select|Wrap|Line Numbers
  1.                <td id="mam" height="180">
  2.                    <iframe id="NewsBody_rich" src="includes/MsgBody.htm"
  3. width="100%" height="100%"
  4.                        onblur="fillTxt()" style="font-family:
  5. Arial"></iframe>
  6.                </td>
  7. >
  8. //Javascript function to be executed
  9.                function setTxt(szText)
  10. {
  11.   var State = new Object()
  12.   var aa;
  13.   NewsBody_rich.document.body.innerHTML = szText;
  14. }
  15.  
>
Question 2:
Expand|Select|Wrap|Line Numbers
  1. UserControl mentioned
  2. <%@ Control Language="C#" AutoEventWireup="true"
  3. CodeFile="AlbumDetailList.ascx.cs" Inherits="usercontrols_AlbumDetailList"
  4. %>
  5. <asp:Panel ID="pnlMain" runat="server" Height="600px" Width="824px">
  6.    <table id="tblMain" width="824" border="0">
  7.        ....
  8.       <tr>
  9.            <td>
  10.                <asp:Panel ID="pnlPhotos" runat="server" Height="100px"
  11. Width="824px">
  12.                </asp:Panel>
  13.            </td>
  14.        </tr>
  15.       ...
  16.   </table>
  17. </asp:Panel>
  18. >
  19. Inside MasterPage:
  20. >
  21. <script language="javascript" type="text/javascript">
  22. ....
  23.   function ConfirmDelete(szText)
  24.    {
  25.        var confirmed = confirm("Are you sure you want to delete the " +
  26. szText + "?");
  27. >
  28.        if(confirmed)
  29.            return true;
  30.        else
  31.            return false;
  32.    }
  33. ....
  34. </script>
  35. >
  36. //Add attributes to delete buttons
  37.    private void InitializeButtonAttributes()
  38.    {
  39.        btnDelete1.Attributes.Add("onclick", "javascript:return
  40. ConfirmDelete('Image/s')");
  41.        btnDelete2.Attributes.Add("onclick", "javascript:return
  42. ConfirmDelete('Image/s')");
  43.    }
  44. >
  45. I need to execute this method:
  46. //Remove Checked in CheckBox
  47.    private void ReInitializeCheckbox()
  48.    {
  49.        foreach (Control ctrl in myPanel.Controls)
  50.        {
  51.            ....
  52.                CheckBox chkPhoto = (CheckBox)ctrl.FindControl(ctrl.ID);
  53. >
  54.                if (chkPhoto.Checked)
  55.                    chkPhoto.Checked = false;
  56.            ...
  57.        }
  58.    }
  59. >
  60.  // As suggested in another forum, I tried this but when cancel is click,
  61. it executed
  62.  //the GetSelectedPhotosForDeletion() method
  63.  function ConfirmDelete(szText)
  64.    {
  65.        var confirmed = confirm("Are you sure you want to delete the " +
  66. szText + "?");
  67. >
  68.        if(confirmed)
  69.            return true;
  70.        else
  71.        {
  72. >
  73.         var allInputs = Form1.getElementsByTagName('INPUT'); //check all
  74. input boxes
  75. >
  76.     for ( var i=0; i<allInputs.length; i++ )
  77.                 {
  78.                                           if ( allInputs.type ==
  79. 'checkbox'
  80. )
  81.                                          {
  82.                                                if ( allInputs.checked)
  83.                                                      allInputs.checked =
  84. false;
  85.                                          }
  86.                                    }
  87.                                    //do the same for 'select' controls and
  88. radio buttons
  89.                        return false;
  90.        }
  91.    }
  92. >
  93. >
  94.  //This gets executed
  95.  protected void btnDelete_Click(object sender, EventArgs e)
  96.    {
  97.              GetSelectedPhotosForDeletion();//even clicking cancel in
  98. confirm this gets executed..
  99.    }
  100. >
  101.  
>
Thanks in advanced..
>
den2005
>
--
MCP Year 2005, Philippines

den 2005
Guest
 
Posts: n/a
#3: Oct 9 '06

re: Javascript Server-side Action Questions..


Thanks Baski for replying...

I tried what you suggested in question 1, it's not working, what is wrong
with this?

Inside Parent user control:

RichTextEditor1.SetEditorContent(dr["Contents"].ToString());

Inside RichTextEditor user control class:

public void SetEditorContent(string contents)
{
this.EditorContent = contents;
//Page.ClientScript.RegisterClientScriptBlock(this.G etType(),
"RunFunction", "setTxt('" + contents + "')");
Page.RegisterStartupScript("StartupScript", "setTxt('" + contents +
"')");
}

The second question has been resolved in another post on this same forum.


--
MCP Year 2005, Philippines


"Baski" wrote:
Quote:
Quote:

Question 1: How do you set the values from server-side to a client-side
control or how do you execute a javascript function without a button click
event?
>
What ever asp.net control post back to your server even handler add
the following code
>
this.Page.RegisterStartupScript("StartupScript","< script>YourJavascriptFunctionName()</script>");
>
>
>
when page post back this method will be called on page load, if needed , you
can also pass value to your javascripr function from server side.
>
like below
>
this.Page.RegisterStartupScript("StartupScript","< script>YourJavascriptFunctionName('param1',
'param2')</script>");
>
Quote:
Question 2: How do you get response from a Confirm() popup window to
uncheck all server-side checkboxes placed in a panle of a web user
control?
>
since you are return true or false in your confirmation , your delete button
event handler will be called back upon true,
there you can write your checkbox selection logic.
>
>
"den 2005" <den2005@discussions.microsoft.comwrote in message
news:84001420-548B-437A-B876-CD07C8778C29@microsoft.com...
Quote:
Hi everybody,

Question 1: How do you set the values from server-side to a client-side
control or how do you execute a javascript function without a button click
event?
Question 2: How do you get response from a Confirm() popup window to
uncheck all server-side checkboxes placed in a panle of a web user
control?

I am using ASP.Net 2.0, Thanks. Need info...

Question 1:
Expand|Select|Wrap|Line Numbers
  1.                 <td id="mam" height="180">
  2.                     <iframe id="NewsBody_rich" src="includes/MsgBody.htm"
  3.  width="100%" height="100%"
  4.                         onblur="fillTxt()" style="font-family:
  5.  Arial"></iframe>
  6.                 </td>
  7.  
  8.  //Javascript function to be executed
  9.                 function setTxt(szText)
  10.  {
  11.    var State = new Object()
  12.    var aa;
  13.    NewsBody_rich.document.body.innerHTML = szText;
  14.  }
  15.  
Question 2:
Expand|Select|Wrap|Line Numbers
  1.  UserControl mentioned
  2.  <%@ Control Language="C#" AutoEventWireup="true"
  3.  CodeFile="AlbumDetailList.ascx.cs" Inherits="usercontrols_AlbumDetailList"
  4.  %>
  5.  <asp:Panel ID="pnlMain" runat="server" Height="600px" Width="824px">
  6.     <table id="tblMain" width="824" border="0">
  7.         ....
  8.        <tr>
  9.             <td>
  10.                 <asp:Panel ID="pnlPhotos" runat="server" Height="100px"
  11.  Width="824px">
  12.                 </asp:Panel>
  13.             </td>
  14.         </tr>
  15.        ...
  16.    </table>
  17.  </asp:Panel>
  18.  
  19.  Inside MasterPage:
  20.  
  21.  <script language="javascript" type="text/javascript">
  22.  ....
  23.    function ConfirmDelete(szText)
  24.     {
  25.         var confirmed = confirm("Are you sure you want to delete the " +
  26.  szText + "?");
  27.  
  28.         if(confirmed)
  29.             return true;
  30.         else
  31.             return false;
  32.     }
  33.  ....
  34.  </script>
  35.  
  36.  //Add attributes to delete buttons
  37.     private void InitializeButtonAttributes()
  38.     {
  39.         btnDelete1.Attributes.Add("onclick", "javascript:return
  40.  ConfirmDelete('Image/s')");
  41.         btnDelete2.Attributes.Add("onclick", "javascript:return
  42.  ConfirmDelete('Image/s')");
  43.     }
  44.  
  45.  I need to execute this method:
  46.  //Remove Checked in CheckBox
  47.     private void ReInitializeCheckbox()
  48.     {
  49.         foreach (Control ctrl in myPanel.Controls)
  50.         {
  51.             ....
  52.                 CheckBox chkPhoto = (CheckBox)ctrl.FindControl(ctrl.ID);
  53.  
  54.                 if (chkPhoto.Checked)
  55.                     chkPhoto.Checked = false;
  56.             ...
  57.         }
  58.     }
  59.  
  60.   // As suggested in another forum, I tried this but when cancel is click,
  61.  it executed
  62.   //the GetSelectedPhotosForDeletion() method
  63.   function ConfirmDelete(szText)
  64.     {
  65.         var confirmed = confirm("Are you sure you want to delete the " +
  66.  szText + "?");
  67.  
  68.         if(confirmed)
  69.             return true;
  70.         else
  71.         {
  72.  
  73.          var allInputs = Form1.getElementsByTagName('INPUT'); //check all
  74.  input boxes
  75.  
  76.      for ( var i=0; i<allInputs.length; i++ )
  77.                  {
  78.                                            if ( allInputs.type ==
  79.  'checkbox'
  80.  )
  81.                                           {
  82.                                                 if ( allInputs.checked)
  83.                                                       allInputs.checked =
  84.  false;
  85.                                           }
  86.                                     }
  87.                                     //do the same for 'select' controls and
  88.  radio buttons
  89.                         return false;
  90.         }
  91.     }
  92.  
  93.  
  94.   //This gets executed
  95.   protected void btnDelete_Click(object sender, EventArgs e)
  96.     {
  97.               GetSelectedPhotosForDeletion();//even clicking cancel in
  98.  confirm this gets executed..
  99.     }
  100.  
  101.  
Thanks in advanced..

den2005

--
MCP Year 2005, Philippines
>
>
>
den 2005
Guest
 
Posts: n/a
#4: Oct 9 '06

re: Javascript Server-side Action Questions..


Baski,

I try to follow what you suggested as answer in question # 1, but it's
not working, Am I missing something or not doing it right?

Inside Parent User Control:

RichTextEditor1.SetEditorContent(dr["Contents"].ToString());

Inside RichTextEditor user control:

public void SetEditorContent(string contents)
{
this.EditorContent = contents;
//Page.ClientScript.RegisterClientScriptBlock(this.G etType(),

// "RunFunction", "setTxt('" + contents + "')");
Page.RegisterStartupScript("StartupScript", "setTxt('" + contents +
"')");
}

The second question has been answered in another post on this same forum.

Dennis
--
MCP Year 2005, Philippines


"Baski" wrote:
Quote:
Quote:

Question 1: How do you set the values from server-side to a client-side
control or how do you execute a javascript function without a button click
event?
>
What ever asp.net control post back to your server even handler add
the following code
>
this.Page.RegisterStartupScript("StartupScript","< script>YourJavascriptFunctionName()</script>");
>
>
>
when page post back this method will be called on page load, if needed , you
can also pass value to your javascripr function from server side.
>
like below
>
this.Page.RegisterStartupScript("StartupScript","< script>YourJavascriptFunctionName('param1',
'param2')</script>");
>
Quote:
Question 2: How do you get response from a Confirm() popup window to
uncheck all server-side checkboxes placed in a panle of a web user
control?
>
since you are return true or false in your confirmation , your delete button
event handler will be called back upon true,
there you can write your checkbox selection logic.
>
>
"den 2005" <den2005@discussions.microsoft.comwrote in message
news:84001420-548B-437A-B876-CD07C8778C29@microsoft.com...
Quote:
Hi everybody,

Question 1: How do you set the values from server-side to a client-side
control or how do you execute a javascript function without a button click
event?
Question 2: How do you get response from a Confirm() popup window to
uncheck all server-side checkboxes placed in a panle of a web user
control?

I am using ASP.Net 2.0, Thanks. Need info...

Question 1:
Expand|Select|Wrap|Line Numbers
  1.                 <td id="mam" height="180">
  2.                     <iframe id="NewsBody_rich" src="includes/MsgBody.htm"
  3.  width="100%" height="100%"
  4.                         onblur="fillTxt()" style="font-family:
  5.  Arial"></iframe>
  6.                 </td>
  7.  
  8.  //Javascript function to be executed
  9.                 function setTxt(szText)
  10.  {
  11.    var State = new Object()
  12.    var aa;
  13.    NewsBody_rich.document.body.innerHTML = szText;
  14.  }
  15.  
Question 2:
Expand|Select|Wrap|Line Numbers
  1.  UserControl mentioned
  2.  <%@ Control Language="C#" AutoEventWireup="true"
  3.  CodeFile="AlbumDetailList.ascx.cs" Inherits="usercontrols_AlbumDetailList"
  4.  %>
  5.  <asp:Panel ID="pnlMain" runat="server" Height="600px" Width="824px">
  6.     <table id="tblMain" width="824" border="0">
  7.         ....
  8.        <tr>
  9.             <td>
  10.                 <asp:Panel ID="pnlPhotos" runat="server" Height="100px"
  11.  Width="824px">
  12.                 </asp:Panel>
  13.             </td>
  14.         </tr>
  15.        ...
  16.    </table>
  17.  </asp:Panel>
  18.  
  19.  Inside MasterPage:
  20.  
  21.  <script language="javascript" type="text/javascript">
  22.  ....
  23.    function ConfirmDelete(szText)
  24.     {
  25.         var confirmed = confirm("Are you sure you want to delete the " +
  26.  szText + "?");
  27.  
  28.         if(confirmed)
  29.             return true;
  30.         else
  31.             return false;
  32.     }
  33.  ....
  34.  </script>
  35.  
  36.  //Add attributes to delete buttons
  37.     private void InitializeButtonAttributes()
  38.     {
  39.         btnDelete1.Attributes.Add("onclick", "javascript:return
  40.  ConfirmDelete('Image/s')");
  41.         btnDelete2.Attributes.Add("onclick", "javascript:return
  42.  ConfirmDelete('Image/s')");
  43.     }
  44.  
  45.  I need to execute this method:
  46.  //Remove Checked in CheckBox
  47.     private void ReInitializeCheckbox()
  48.     {
  49.         foreach (Control ctrl in myPanel.Controls)
  50.         {
  51.             ....
  52.                 CheckBox chkPhoto = (CheckBox)ctrl.FindControl(ctrl.ID);
  53.  
  54.                 if (chkPhoto.Checked)
  55.                     chkPhoto.Checked = false;
  56.             ...
  57.         }
  58.     }
  59.  
  60.   // As suggested in another forum, I tried this but when cancel is click,
  61.  it executed
  62.   //the GetSelectedPhotosForDeletion() method
  63.   function ConfirmDelete(szText)
  64.     {
  65.         var confirmed = confirm("Are you sure you want to delete the " +
  66.  szText + "?");
  67.  
  68.         if(confirmed)
  69.             return true;
  70.         else
  71.         {
  72.  
  73.          var allInputs = Form1.getElementsByTagName('INPUT'); //check all
  74.  input boxes
  75.  
  76.      for ( var i=0; i<allInputs.length; i++ )
  77.                  {
  78.                                            if ( allInputs.type ==
  79.  'checkbox'
  80.  )
  81.                                           {
  82.                                                 if ( allInputs.checked)
  83.                                                       allInputs.checked =
  84.  false;
  85.                                           }
  86.                                     }
  87.                                     //do the same for 'select' controls and
  88.  radio buttons
  89.                         return false;
  90.         }
  91.     }
  92.  
  93.  
  94.   //This gets executed
  95.   protected void btnDelete_Click(object sender, EventArgs e)
  96.     {
  97.               GetSelectedPhotosForDeletion();//even clicking cancel in
  98.  confirm this gets executed..
  99.     }
  100.  
  101.  
Thanks in advanced..

den2005

--
MCP Year 2005, Philippines
>
>
>
Baski
Guest
 
Posts: n/a
#5: Oct 9 '06

re: Javascript Server-side Action Questions..


What error you got ? if you didn't get error , can you please uncheck
Disable Script Debugging (Ie and other) in IE's tools->iption->Advanced tab,
and rerun your application. It seems like you should get object not defined
error from javascript.



"den 2005" <den2005@discussions.microsoft.comwrote in message
news:F3EEAA17-4234-4FB7-A970-81FED24C4B1D@microsoft.com...
Quote:
Thanks Baski for replying...
>
I tried what you suggested in question 1, it's not working, what is wrong
with this?
>
Inside Parent user control:
>
RichTextEditor1.SetEditorContent(dr["Contents"].ToString());
>
Inside RichTextEditor user control class:
>
public void SetEditorContent(string contents)
{
this.EditorContent = contents;
//Page.ClientScript.RegisterClientScriptBlock(this.G etType(),
"RunFunction", "setTxt('" + contents + "')");
Page.RegisterStartupScript("StartupScript", "setTxt('" + contents +
"')");
}
>
The second question has been resolved in another post on this same forum.
>
>
--
MCP Year 2005, Philippines
>
>
"Baski" wrote:
>
Quote:
Quote:
>
Question 1: How do you set the values from server-side to a
client-side
control or how do you execute a javascript function without a button
click
event?
>>
> What ever asp.net control post back to your server even handler
>add
>the following code
>>
>this.Page.RegisterStartupScript("StartupScript"," <script>YourJavascriptFunctionName()</script>");
>>
>>
>>
>when page post back this method will be called on page load, if needed ,
>you
>can also pass value to your javascripr function from server side.
>>
>like below
>>
>this.Page.RegisterStartupScript("StartupScript"," <script>YourJavascriptFunctionName('param1',
>'param2')</script>");
>>
Quote:
Question 2: How do you get response from a Confirm() popup window to
uncheck all server-side checkboxes placed in a panle of a web user
control?
>>
>since you are return true or false in your confirmation , your delete
>button
>event handler will be called back upon true,
>there you can write your checkbox selection logic.
>>
>>
>"den 2005" <den2005@discussions.microsoft.comwrote in message
>news:84001420-548B-437A-B876-CD07C8778C29@microsoft.com...
Quote:
Hi everybody,
>
Question 1: How do you set the values from server-side to a
client-side
control or how do you execute a javascript function without a button
click
event?
Question 2: How do you get response from a Confirm() popup window to
uncheck all server-side checkboxes placed in a panle of a web user
control?
>
I am using ASP.Net 2.0, Thanks. Need info...
>
Question 1:
Expand|Select|Wrap|Line Numbers
  1.                <td id="mam" height="180">
  2.                    <iframe id="NewsBody_rich"
  3. src="includes/MsgBody.htm"
  4. width="100%" height="100%"
  5.                        onblur="fillTxt()" style="font-family:
  6. Arial"></iframe>
  7.                </td>
  8. >
  9. //Javascript function to be executed
  10.                function setTxt(szText)
  11. {
  12.   var State = new Object()
  13.   var aa;
  14.   NewsBody_rich.document.body.innerHTML = szText;
  15. }
  16.  
>
Question 2:
Expand|Select|Wrap|Line Numbers
  1. UserControl mentioned
  2. <%@ Control Language="C#" AutoEventWireup="true"
  3. CodeFile="AlbumDetailList.ascx.cs"
  4. Inherits="usercontrols_AlbumDetailList"
  5. %>
  6. <asp:Panel ID="pnlMain" runat="server" Height="600px" Width="824px">
  7.    <table id="tblMain" width="824" border="0">
  8.        ....
  9.       <tr>
  10.            <td>
  11.                <asp:Panel ID="pnlPhotos" runat="server" Height="100px"
  12. Width="824px">
  13.                </asp:Panel>
  14.            </td>
  15.        </tr>
  16.       ...
  17.   </table>
  18. </asp:Panel>
  19. >
  20. Inside MasterPage:
  21. >
  22. <script language="javascript" type="text/javascript">
  23. ....
  24.   function ConfirmDelete(szText)
  25.    {
  26.        var confirmed = confirm("Are you sure you want to delete the " +
  27. szText + "?");
  28. >
  29.        if(confirmed)
  30.            return true;
  31.        else
  32.            return false;
  33.    }
  34. ....
  35. </script>
  36. >
  37. //Add attributes to delete buttons
  38.    private void InitializeButtonAttributes()
  39.    {
  40.        btnDelete1.Attributes.Add("onclick", "javascript:return
  41. ConfirmDelete('Image/s')");
  42.        btnDelete2.Attributes.Add("onclick", "javascript:return
  43. ConfirmDelete('Image/s')");
  44.    }
  45. >
  46. I need to execute this method:
  47. //Remove Checked in CheckBox
  48.    private void ReInitializeCheckbox()
  49.    {
  50.        foreach (Control ctrl in myPanel.Controls)
  51.        {
  52.            ....
  53.                CheckBox chkPhoto = (CheckBox)ctrl.FindControl(ctrl.ID);
  54. >
  55.                if (chkPhoto.Checked)
  56.                    chkPhoto.Checked = false;
  57.            ...
  58.        }
  59.    }
  60. >
  61.  // As suggested in another forum, I tried this but when cancel is
  62. click,
  63. it executed
  64.  //the GetSelectedPhotosForDeletion() method
  65.  function ConfirmDelete(szText)
  66.    {
  67.        var confirmed = confirm("Are you sure you want to delete the " +
  68. szText + "?");
  69. >
  70.        if(confirmed)
  71.            return true;
  72.        else
  73.        {
  74. >
  75.         var allInputs = Form1.getElementsByTagName('INPUT'); //check
  76. all
  77. input boxes
  78. >
  79.     for ( var i=0; i<allInputs.length; i++ )
  80.                 {
  81.                                           if ( allInputs.type ==
  82. 'checkbox'
  83. )
  84.                                          {
  85.                                                if ( allInputs.checked)
  86.                                                      allInputs.checked
  87. =
  88. false;
  89.                                          }
  90.                                    }
  91.                                    //do the same for 'select' controls
  92. and
  93. radio buttons
  94.                        return false;
  95.        }
  96.    }
  97. >
  98. >
  99.  //This gets executed
  100.  protected void btnDelete_Click(object sender, EventArgs e)
  101.    {
  102.              GetSelectedPhotosForDeletion();//even clicking cancel in
  103. confirm this gets executed..
  104.    }
  105. >
  106.  
>
Thanks in advanced..
>
den2005
>
--
MCP Year 2005, Philippines
>>
>>
>>

den 2005
Guest
 
Posts: n/a
#6: Oct 10 '06

re: Javascript Server-side Action Questions..


Baski,
Where exectly would I expect to see the error, in browser window, or
Event viewer, I uncheck the Disable Script Debugging (Ie and other) and rerun
application, still no change...what do you meant by "you should get object
not defined error from javascript" exactly? I am not getting this error
message in browser window or event viewer...


--
MCP Year 2005, Philippines


"Baski" wrote:
Quote:
What error you got ? if you didn't get error , can you please uncheck
Disable Script Debugging (Ie and other) in IE's tools->iption->Advanced tab,
and rerun your application. It seems like you should get object not defined
error from javascript.
>
>
>
"den 2005" <den2005@discussions.microsoft.comwrote in message
news:F3EEAA17-4234-4FB7-A970-81FED24C4B1D@microsoft.com...
Quote:
Thanks Baski for replying...

I tried what you suggested in question 1, it's not working, what is wrong
with this?

Inside Parent user control:

RichTextEditor1.SetEditorContent(dr["Contents"].ToString());

Inside RichTextEditor user control class:

public void SetEditorContent(string contents)
{
this.EditorContent = contents;
//Page.ClientScript.RegisterClientScriptBlock(this.G etType(),
"RunFunction", "setTxt('" + contents + "')");
Page.RegisterStartupScript("StartupScript", "setTxt('" + contents +
"')");
}

The second question has been resolved in another post on this same forum.


--
MCP Year 2005, Philippines


"Baski" wrote:
Quote:

Question 1: How do you set the values from server-side to a
client-side
control or how do you execute a javascript function without a button
click
event?
>
What ever asp.net control post back to your server even handler
add
the following code
>
this.Page.RegisterStartupScript("StartupScript","< script>YourJavascriptFunctionName()</script>");
>
>
>
when page post back this method will be called on page load, if needed ,
you
can also pass value to your javascripr function from server side.
>
like below
>
this.Page.RegisterStartupScript("StartupScript","< script>YourJavascriptFunctionName('param1',
'param2')</script>");
>
Question 2: How do you get response from a Confirm() popup window to
uncheck all server-side checkboxes placed in a panle of a web user
control?
>
since you are return true or false in your confirmation , your delete
button
event handler will be called back upon true,
there you can write your checkbox selection logic.
>
>
"den 2005" <den2005@discussions.microsoft.comwrote in message
news:84001420-548B-437A-B876-CD07C8778C29@microsoft.com...
Hi everybody,

Question 1: How do you set the values from server-side to a
client-side
control or how do you execute a javascript function without a button
click
event?
Question 2: How do you get response from a Confirm() popup window to
uncheck all server-side checkboxes placed in a panle of a web user
control?

I am using ASP.Net 2.0, Thanks. Need info...

Question 1:
Expand|Select|Wrap|Line Numbers
  1.                 <td id="mam" height="180">
  2.                     <iframe id="NewsBody_rich"
  3.  src="includes/MsgBody.htm"
  4.  width="100%" height="100%"
  5.                         onblur="fillTxt()" style="font-family:
  6.  Arial"></iframe>
  7.                 </td>
  8.  
  9.  //Javascript function to be executed
  10.                 function setTxt(szText)
  11.  {
  12.    var State = new Object()
  13.    var aa;
  14.    NewsBody_rich.document.body.innerHTML = szText;
  15.  }
  16.  
Question 2:
Expand|Select|Wrap|Line Numbers
  1.  UserControl mentioned
  2.  <%@ Control Language="C#" AutoEventWireup="true"
  3.  CodeFile="AlbumDetailList.ascx.cs"
  4.  Inherits="usercontrols_AlbumDetailList"
  5.  %>
  6.  <asp:Panel ID="pnlMain" runat="server" Height="600px" Width="824px">
  7.     <table id="tblMain" width="824" border="0">
  8.         ....
  9.        <tr>
  10.             <td>
  11.                 <asp:Panel ID="pnlPhotos" runat="server" Height="100px"
  12.  Width="824px">
  13.                 </asp:Panel>
  14.             </td>
  15.         </tr>
  16.        ...
  17.    </table>
  18.  </asp:Panel>
  19.  
  20.  Inside MasterPage:
  21.  
  22.  <script language="javascript" type="text/javascript">
  23.  ....
  24.    function ConfirmDelete(szText)
  25.     {
  26.         var confirmed = confirm("Are you sure you want to delete the " +
  27.  szText + "?");
  28.  
  29.         if(confirmed)
  30.             return true;
  31.         else
  32.             return false;
  33.     }
  34.  ....
  35.  </script>
  36.  
  37.  //Add attributes to delete buttons
  38.     private void InitializeButtonAttributes()
  39.     {
  40.         btnDelete1.Attributes.Add("onclick", "javascript:return
  41.  ConfirmDelete('Image/s')");
  42.         btnDelete2.Attributes.Add("onclick", "javascript:return
  43.  ConfirmDelete('Image/s')");
  44.     }
  45.  
  46.  I need to execute this method:
  47.  //Remove Checked in CheckBox
  48.     private void ReInitializeCheckbox()
  49.     {
  50.         foreach (Control ctrl in myPanel.Controls)
  51.         {
  52.             ....
  53.                 CheckBox chkPhoto = (CheckBox)ctrl.FindControl(ctrl.ID);
  54.  
  55.                 if (chkPhoto.Checked)
  56.                     chkPhoto.Checked = false;
  57.             ...
  58.         }
  59.     }
  60.  
  61.   // As suggested in another forum, I tried this but when cancel is
  62.  click,
  63.  it executed
  64.   //the GetSelectedPhotosForDeletion() method
  65.   function ConfirmDelete(szText)
  66.     {
  67.         var confirmed = confirm("Are you sure you want to delete the " +
  68.  szText + "?");
  69.  
  70.         if(confirmed)
  71.             return true;
  72.         else
  73.         {
  74.  
  75.          var allInputs = Form1.getElementsByTagName('INPUT'); //check
  76.  all
  77.  input boxes
  78.  
  79.      for ( var i=0; i<allInputs.length; i++ )
  80.                  {
  81.                                            if ( allInputs.type ==
  82.  'checkbox'
  83.  )
  84.                                           {
  85.                                                 if ( allInputs.checked)
  86.                                                       allInputs.checked
  87.  =
  88.  false;
  89.                                           }
  90.                                     }
  91.                                     //do the same for 'select' controls
  92.  and
  93.  radio buttons
  94.                         return false;
  95.         }
  96.     }
  97.  
  98.  
  99.   //This gets executed
  100.   protected void btnDelete_Click(object sender, EventArgs e)
  101.     {
  102.               GetSelectedPhotosForDeletion();//even clicking cancel in
  103.  confirm this gets executed..
  104.     }
  105.  
  106.  
Thanks in advanced..

den2005

--
MCP Year 2005, Philippines
>
>
>
>
>
>
Baski
Guest
 
Posts: n/a
#7: Oct 10 '06

re: Javascript Server-side Action Questions..


I thought you might get java script error in pop up browser window. ON your
javasctip function try to add alert message as first line and make sure it
got executed. If it shows the alert message , set the break point in your
javascript function and debug.

"den 2005" <den2005@discussions.microsoft.comwrote in message
news:D3609657-9018-4046-A1C2-390733ECC4BA@microsoft.com...
Quote:
Baski,
Where exectly would I expect to see the error, in browser window, or
Event viewer, I uncheck the Disable Script Debugging (Ie and other) and
rerun
application, still no change...what do you meant by "you should get object
not defined error from javascript" exactly? I am not getting this error
message in browser window or event viewer...
>
>
--
MCP Year 2005, Philippines
>
>
"Baski" wrote:
>
Quote:
>What error you got ? if you didn't get error , can you please uncheck
>Disable Script Debugging (Ie and other) in IE's tools->iption->Advanced
>tab,
>and rerun your application. It seems like you should get object not
>defined
>error from javascript.
>>
>>
>>
>"den 2005" <den2005@discussions.microsoft.comwrote in message
>news:F3EEAA17-4234-4FB7-A970-81FED24C4B1D@microsoft.com...
Quote:
Thanks Baski for replying...
>
I tried what you suggested in question 1, it's not working, what is
wrong
with this?
>
Inside Parent user control:
>
RichTextEditor1.SetEditorContent(dr["Contents"].ToString());
>
Inside RichTextEditor user control class:
>
public void SetEditorContent(string contents)
{
this.EditorContent = contents;
//Page.ClientScript.RegisterClientScriptBlock(this.G etType(),
"RunFunction", "setTxt('" + contents + "')");
Page.RegisterStartupScript("StartupScript", "setTxt('" +
contents +
"')");
}
>
The second question has been resolved in another post on this same
forum.
>
>
--
MCP Year 2005, Philippines
>
>
"Baski" wrote:
>
>
Question 1: How do you set the values from server-side to a
client-side
control or how do you execute a javascript function without a button
click
event?
>>
> What ever asp.net control post back to your server even
>handler
>add
>the following code
>>
>this.Page.RegisterStartupScript("StartupScript"," <script>YourJavascriptFunctionName()</script>");
>>
>>
>>
>when page post back this method will be called on page load, if needed
>,
>you
>can also pass value to your javascripr function from server side.
>>
>like below
>>
>this.Page.RegisterStartupScript("StartupScript"," <script>YourJavascriptFunctionName('param1',
>'param2')</script>");
>>
Question 2: How do you get response from a Confirm() popup window
to
uncheck all server-side checkboxes placed in a panle of a web user
control?
>>
>since you are return true or false in your confirmation , your delete
>button
>event handler will be called back upon true,
>there you can write your checkbox selection logic.
>>
>>
>"den 2005" <den2005@discussions.microsoft.comwrote in message
>news:84001420-548B-437A-B876-CD07C8778C29@microsoft.com...
Hi everybody,
>
Question 1: How do you set the values from server-side to a
client-side
control or how do you execute a javascript function without a button
click
event?
Question 2: How do you get response from a Confirm() popup window
to
uncheck all server-side checkboxes placed in a panle of a web user
control?
>
I am using ASP.Net 2.0, Thanks. Need info...
>
Question 1:
Expand|Select|Wrap|Line Numbers
  1.                <td id="mam" height="180">
  2.                    <iframe id="NewsBody_rich"
  3. src="includes/MsgBody.htm"
  4. width="100%" height="100%"
  5.                        onblur="fillTxt()" style="font-family:
  6. Arial"></iframe>
  7.                </td>
  8. >
  9. //Javascript function to be executed
  10.                function setTxt(szText)
  11. {
  12.   var State = new Object()
  13.   var aa;
  14.   NewsBody_rich.document.body.innerHTML = szText;
  15. }
  16.  
>
Question 2:
Expand|Select|Wrap|Line Numbers
  1. UserControl mentioned
  2. <%@ Control Language="C#" AutoEventWireup="true"
  3. CodeFile="AlbumDetailList.ascx.cs"
  4. Inherits="usercontrols_AlbumDetailList"
  5. %>
  6. <asp:Panel ID="pnlMain" runat="server" Height="600px" Width="824px">
  7.    <table id="tblMain" width="824" border="0">
  8.        ....
  9.       <tr>
  10.            <td>
  11.                <asp:Panel ID="pnlPhotos" runat="server"
  12. Height="100px"
  13. Width="824px">
  14.                </asp:Panel>
  15.            </td>
  16.        </tr>
  17.       ...
  18.   </table>
  19. </asp:Panel>
  20. >
  21. Inside MasterPage:
  22. >
  23. <script language="javascript" type="text/javascript">
  24. ....
  25.   function ConfirmDelete(szText)
  26.    {
  27.        var confirmed = confirm("Are you sure you want to delete the
  28. " +
  29. szText + "?");
  30. >
  31.        if(confirmed)
  32.            return true;
  33.        else
  34.            return false;
  35.    }
  36. ....
  37. </script>
  38. >
  39. //Add attributes to delete buttons
  40.    private void InitializeButtonAttributes()
  41.    {
  42.        btnDelete1.Attributes.Add("onclick", "javascript:return
  43. ConfirmDelete('Image/s')");
  44.        btnDelete2.Attributes.Add("onclick", "javascript:return
  45. ConfirmDelete('Image/s')");
  46.    }
  47. >
  48. I need to execute this method:
  49. //Remove Checked in CheckBox
  50.    private void ReInitializeCheckbox()
  51.    {
  52.        foreach (Control ctrl in myPanel.Controls)
  53.        {
  54.            ....
  55.                CheckBox chkPhoto =
  56. (CheckBox)ctrl.FindControl(ctrl.ID);
  57. >
  58.                if (chkPhoto.Checked)
  59.                    chkPhoto.Checked = false;
  60.            ...
  61.        }
  62.    }
  63. >
  64.  // As suggested in another forum, I tried this but when cancel is
  65. click,
  66. it executed
  67.  //the GetSelectedPhotosForDeletion() method
  68.  function ConfirmDelete(szText)
  69.    {
  70.        var confirmed = confirm("Are you sure you want to delete the
  71. " +
  72. szText + "?");
  73. >
  74.        if(confirmed)
  75.            return true;
  76.        else
  77.        {
  78. >
  79.         var allInputs = Form1.getElementsByTagName('INPUT'); //check
  80. all
  81. input boxes
  82. >
  83.     for ( var i=0; i<allInputs.length; i++ )
  84.                 {
  85.                                           if ( allInputs.type ==
  86. 'checkbox'
  87. )
  88.                                          {
  89.                                                if (
  90. allInputs.checked)
  91. >
  92. allInputs.checked
  93. =
  94. false;
  95.                                          }
  96.                                    }
  97.                                    //do the same for 'select'
  98. controls
  99. and
  100. radio buttons
  101.                        return false;
  102.        }
  103.    }
  104. >
  105. >
  106.  //This gets executed
  107.  protected void btnDelete_Click(object sender, EventArgs e)
  108.    {
  109.              GetSelectedPhotosForDeletion();//even clicking cancel
  110. in
  111. confirm this gets executed..
  112.    }
  113. >
  114.  
>
Thanks in advanced..
>
den2005
>
--
MCP Year 2005, Philippines
>>
>>
>>
>>
>>
>>

Closed Thread