Javascript Server-side Action Questions..

G

Guest

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:
Code:
                <td id="mam" height="180">
                    <iframe id="NewsBody_rich" src="includes/MsgBody.htm" 
width="100%" height="100%"
                        onblur="fillTxt()" style="font-family: 
Arial"></iframe>
                </td>
		
		//Javascript function to be executed
                function setTxt(szText)
		{
		  var State = new Object()
		  var aa;
		  NewsBody_rich.document.body.innerHTML = szText; 
		}

Question 2:
Code:
UserControl mentioned
<%@ Control Language="C#" AutoEventWireup="true" 
CodeFile="AlbumDetailList.ascx.cs" Inherits="usercontrols_AlbumDetailList" %> 
<asp:Panel ID="pnlMain" runat="server" Height="600px" Width="824px"> 
    <table id="tblMain" width="824" border="0"> 
        .... 
       <tr> 
            <td> 
                <asp:Panel ID="pnlPhotos" runat="server" Height="100px" 
Width="824px"> 
                </asp:Panel> 
            </td> 
        </tr> 
       ... 
   </table> 
</asp:Panel> 

Inside MasterPage:

<script language="javascript" type="text/javascript"> 
..... 
   function ConfirmDelete(szText) 
    { 
        var confirmed = confirm("Are you sure you want to delete the " + 
szText + "?"); 
         
        if(confirmed) 
            return true; 
        else 
            return false; 
    } 
..... 
</script> 

 //Add attributes to delete buttons 
    private void InitializeButtonAttributes() 
    { 
        btnDelete1.Attributes.Add("onclick", "JavaScript:return 
ConfirmDelete('Image/s')"); 
        btnDelete2.Attributes.Add("onclick", "JavaScript:return 
ConfirmDelete('Image/s')"); 
    } 

I need to execute this method: 
 //Remove Checked in CheckBox 
    private void ReInitializeCheckbox() 
    { 
        foreach (Control ctrl in myPanel.Controls) 
        { 
            .... 
                CheckBox chkPhoto = (CheckBox)ctrl.FindControl(ctrl.ID); 

                if (chkPhoto.Checked) 
                    chkPhoto.Checked = false; 
            ... 
        } 
    } 

  // As suggested in another forum, I tried this but when cancel is click, 
it executed 
  //the GetSelectedPhotosForDeletion() method
  function ConfirmDelete(szText) 
    { 
        var confirmed = confirm("Are you sure you want to delete the " + 
szText + "?"); 
                 
        if(confirmed) 
            return true; 
        else 
        { 

         var allInputs = Form1.getElementsByTagName('INPUT'); //check all 
input boxes 

     for ( var i=0; i<allInputs.length; i++ ) 
                 { 
                                           if ( allInputs.type == 'checkbox' 
) 
                                          { 
                                                if ( allInputs.checked) 
                                                      allInputs.checked = 
false; 
                                          } 
                                    } 
                                    //do the same for 'select' controls and 
radio buttons 
                        return false; 
        } 
    } 


  //This gets executed
  protected void btnDelete_Click(object sender, EventArgs e) 
    { 
              GetSelectedPhotosForDeletion();//even clicking cancel in 
confirm this gets executed.. 
    }

Thanks in advanced..

den2005
 
B

Baski

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') said:
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 said:
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:
Code:
<td id="mam" height="180">
<iframe id="NewsBody_rich" src="includes/MsgBody.htm"
width="100%" height="100%"
onblur="fillTxt()" style="font-family:
Arial"></iframe>
</td>

//Javascript function to be executed
function setTxt(szText)
{
var State = new Object()
var aa;
NewsBody_rich.document.body.innerHTML = szText;
}

Question 2:
Code:
UserControl mentioned
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="AlbumDetailList.ascx.cs" Inherits="usercontrols_AlbumDetailList" 
%>
<asp:Panel ID="pnlMain" runat="server" Height="600px" Width="824px">
<table id="tblMain" width="824" border="0">
....
<tr>
<td>
<asp:Panel ID="pnlPhotos" runat="server" Height="100px"
Width="824px">
</asp:Panel>
</td>
</tr>
...
</table>
</asp:Panel>

Inside MasterPage:

<script language="javascript" type="text/javascript">
....
function ConfirmDelete(szText)
{
var confirmed = confirm("Are you sure you want to delete the " +
szText + "?");

if(confirmed)
return true;
else
return false;
}
....
</script>

//Add attributes to delete buttons
private void InitializeButtonAttributes()
{
btnDelete1.Attributes.Add("onclick", "JavaScript:return
ConfirmDelete('Image/s')");
btnDelete2.Attributes.Add("onclick", "JavaScript:return
ConfirmDelete('Image/s')");
}

I need to execute this method:
//Remove Checked in CheckBox
private void ReInitializeCheckbox()
{
foreach (Control ctrl in myPanel.Controls)
{
....
CheckBox chkPhoto = (CheckBox)ctrl.FindControl(ctrl.ID);

if (chkPhoto.Checked)
chkPhoto.Checked = false;
...
}
}

// As suggested in another forum, I tried this but when cancel is click,
it executed
//the GetSelectedPhotosForDeletion() method
function ConfirmDelete(szText)
{
var confirmed = confirm("Are you sure you want to delete the " +
szText + "?");

if(confirmed)
return true;
else
{

var allInputs = Form1.getElementsByTagName('INPUT'); //check all
input boxes

for ( var i=0; i<allInputs.length; i++ )
{
if ( allInputs.type == 
'checkbox'
)
{
if ( allInputs.checked)
allInputs.checked =
false;
}
}
//do the same for 'select' controls and
radio buttons
return false;
}
}


//This gets executed
protected void btnDelete_Click(object sender, EventArgs e)
{
GetSelectedPhotosForDeletion();//even clicking cancel in
confirm this gets executed..
}

Thanks in advanced..

den2005
 
G

Guest

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.GetType(),
"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 said:
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') said:
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 said:
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:
Code:
<td id="mam" height="180">
<iframe id="NewsBody_rich" src="includes/MsgBody.htm"
width="100%" height="100%"
onblur="fillTxt()" style="font-family:
Arial"></iframe>
</td>

//Javascript function to be executed
function setTxt(szText)
{
var State = new Object()
var aa;
NewsBody_rich.document.body.innerHTML = szText;
}

Question 2:
Code:
UserControl mentioned
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="AlbumDetailList.ascx.cs" Inherits="usercontrols_AlbumDetailList" 
%>
<asp:Panel ID="pnlMain" runat="server" Height="600px" Width="824px">
<table id="tblMain" width="824" border="0">
....
<tr>
<td>
<asp:Panel ID="pnlPhotos" runat="server" Height="100px"
Width="824px">
</asp:Panel>
</td>
</tr>
...
</table>
</asp:Panel>

Inside MasterPage:

<script language="javascript" type="text/javascript">
....
function ConfirmDelete(szText)
{
var confirmed = confirm("Are you sure you want to delete the " +
szText + "?");

if(confirmed)
return true;
else
return false;
}
....
</script>

//Add attributes to delete buttons
private void InitializeButtonAttributes()
{
btnDelete1.Attributes.Add("onclick", "JavaScript:return
ConfirmDelete('Image/s')");
btnDelete2.Attributes.Add("onclick", "JavaScript:return
ConfirmDelete('Image/s')");
}

I need to execute this method:
//Remove Checked in CheckBox
private void ReInitializeCheckbox()
{
foreach (Control ctrl in myPanel.Controls)
{
....
CheckBox chkPhoto = (CheckBox)ctrl.FindControl(ctrl.ID);

if (chkPhoto.Checked)
chkPhoto.Checked = false;
...
}
}

// As suggested in another forum, I tried this but when cancel is click,
it executed
//the GetSelectedPhotosForDeletion() method
function ConfirmDelete(szText)
{
var confirmed = confirm("Are you sure you want to delete the " +
szText + "?");

if(confirmed)
return true;
else
{

var allInputs = Form1.getElementsByTagName('INPUT'); //check all
input boxes

for ( var i=0; i<allInputs.length; i++ )
{
if ( allInputs.type == 
'checkbox'
)
{
if ( allInputs.checked)
allInputs.checked =
false;
}
}
//do the same for 'select' controls and
radio buttons
return false;
}
}


//This gets executed
protected void btnDelete_Click(object sender, EventArgs e)
{
GetSelectedPhotosForDeletion();//even clicking cancel in
confirm this gets executed..
}

Thanks in advanced..

den2005
 
G

Guest

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.GetType(),

// "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 said:
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') said:
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 said:
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:
Code:
<td id="mam" height="180">
<iframe id="NewsBody_rich" src="includes/MsgBody.htm"
width="100%" height="100%"
onblur="fillTxt()" style="font-family:
Arial"></iframe>
</td>

//Javascript function to be executed
function setTxt(szText)
{
var State = new Object()
var aa;
NewsBody_rich.document.body.innerHTML = szText;
}

Question 2:
Code:
UserControl mentioned
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="AlbumDetailList.ascx.cs" Inherits="usercontrols_AlbumDetailList" 
%>
<asp:Panel ID="pnlMain" runat="server" Height="600px" Width="824px">
<table id="tblMain" width="824" border="0">
....
<tr>
<td>
<asp:Panel ID="pnlPhotos" runat="server" Height="100px"
Width="824px">
</asp:Panel>
</td>
</tr>
...
</table>
</asp:Panel>

Inside MasterPage:

<script language="javascript" type="text/javascript">
....
function ConfirmDelete(szText)
{
var confirmed = confirm("Are you sure you want to delete the " +
szText + "?");

if(confirmed)
return true;
else
return false;
}
....
</script>

//Add attributes to delete buttons
private void InitializeButtonAttributes()
{
btnDelete1.Attributes.Add("onclick", "JavaScript:return
ConfirmDelete('Image/s')");
btnDelete2.Attributes.Add("onclick", "JavaScript:return
ConfirmDelete('Image/s')");
}

I need to execute this method:
//Remove Checked in CheckBox
private void ReInitializeCheckbox()
{
foreach (Control ctrl in myPanel.Controls)
{
....
CheckBox chkPhoto = (CheckBox)ctrl.FindControl(ctrl.ID);

if (chkPhoto.Checked)
chkPhoto.Checked = false;
...
}
}

// As suggested in another forum, I tried this but when cancel is click,
it executed
//the GetSelectedPhotosForDeletion() method
function ConfirmDelete(szText)
{
var confirmed = confirm("Are you sure you want to delete the " +
szText + "?");

if(confirmed)
return true;
else
{

var allInputs = Form1.getElementsByTagName('INPUT'); //check all
input boxes

for ( var i=0; i<allInputs.length; i++ )
{
if ( allInputs.type == 
'checkbox'
)
{
if ( allInputs.checked)
allInputs.checked =
false;
}
}
//do the same for 'select' controls and
radio buttons
return false;
}
}


//This gets executed
protected void btnDelete_Click(object sender, EventArgs e)
{
GetSelectedPhotosForDeletion();//even clicking cancel in
confirm this gets executed..
}

Thanks in advanced..

den2005
 
B

Baski

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 said:
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.GetType(),
"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 said:
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') said:
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 said:
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:
Code:
<td id="mam" height="180">
<iframe id="NewsBody_rich" 
src="includes/MsgBody.htm"
width="100%" height="100%"
onblur="fillTxt()" style="font-family:
Arial"></iframe>
</td>

//Javascript function to be executed
function setTxt(szText)
{
var State = new Object()
var aa;
NewsBody_rich.document.body.innerHTML = szText;
}

Question 2:
Code:
UserControl mentioned
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="AlbumDetailList.ascx.cs" 
Inherits="usercontrols_AlbumDetailList"
%>
<asp:Panel ID="pnlMain" runat="server" Height="600px" Width="824px">
<table id="tblMain" width="824" border="0">
....
<tr>
<td>
<asp:Panel ID="pnlPhotos" runat="server" Height="100px"
Width="824px">
</asp:Panel>
</td>
</tr>
...
</table>
</asp:Panel>

Inside MasterPage:

<script language="javascript" type="text/javascript">
....
function ConfirmDelete(szText)
{
var confirmed = confirm("Are you sure you want to delete the " +
szText + "?");

if(confirmed)
return true;
else
return false;
}
....
</script>

//Add attributes to delete buttons
private void InitializeButtonAttributes()
{
btnDelete1.Attributes.Add("onclick", "JavaScript:return
ConfirmDelete('Image/s')");
btnDelete2.Attributes.Add("onclick", "JavaScript:return
ConfirmDelete('Image/s')");
}

I need to execute this method:
//Remove Checked in CheckBox
private void ReInitializeCheckbox()
{
foreach (Control ctrl in myPanel.Controls)
{
....
CheckBox chkPhoto = (CheckBox)ctrl.FindControl(ctrl.ID);

if (chkPhoto.Checked)
chkPhoto.Checked = false;
...
}
}

// As suggested in another forum, I tried this but when cancel is 
click,
it executed
//the GetSelectedPhotosForDeletion() method
function ConfirmDelete(szText)
{
var confirmed = confirm("Are you sure you want to delete the " +
szText + "?");

if(confirmed)
return true;
else
{

var allInputs = Form1.getElementsByTagName('INPUT'); //check 
all
input boxes

for ( var i=0; i<allInputs.length; i++ )
{
if ( allInputs.type ==
'checkbox'
)
{
if ( allInputs.checked)
allInputs.checked 
=
false;
}
}
//do the same for 'select' controls 
and
radio buttons
return false;
}
}


//This gets executed
protected void btnDelete_Click(object sender, EventArgs e)
{
GetSelectedPhotosForDeletion();//even clicking cancel in
confirm this gets executed..
}

Thanks in advanced..

den2005
 
G

Guest

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 said:
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 said:
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.GetType(),
"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 said:
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.


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:
Code:
<td id="mam" height="180">
<iframe id="NewsBody_rich" 
src="includes/MsgBody.htm"
width="100%" height="100%"
onblur="fillTxt()" style="font-family:
Arial"></iframe>
</td>

//Javascript function to be executed
function setTxt(szText)
{
var State = new Object()
var aa;
NewsBody_rich.document.body.innerHTML = szText;
}

Question 2:
Code:
UserControl mentioned
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="AlbumDetailList.ascx.cs" 
Inherits="usercontrols_AlbumDetailList"
%>
<asp:Panel ID="pnlMain" runat="server" Height="600px" Width="824px">
<table id="tblMain" width="824" border="0">
....
<tr>
<td>
<asp:Panel ID="pnlPhotos" runat="server" Height="100px"
Width="824px">
</asp:Panel>
</td>
</tr>
...
</table>
</asp:Panel>

Inside MasterPage:

<script language="javascript" type="text/javascript">
....
function ConfirmDelete(szText)
{
var confirmed = confirm("Are you sure you want to delete the " +
szText + "?");

if(confirmed)
return true;
else
return false;
}
....
</script>

//Add attributes to delete buttons
private void InitializeButtonAttributes()
{
btnDelete1.Attributes.Add("onclick", "JavaScript:return
ConfirmDelete('Image/s')");
btnDelete2.Attributes.Add("onclick", "JavaScript:return
ConfirmDelete('Image/s')");
}

I need to execute this method:
//Remove Checked in CheckBox
private void ReInitializeCheckbox()
{
foreach (Control ctrl in myPanel.Controls)
{
....
CheckBox chkPhoto = (CheckBox)ctrl.FindControl(ctrl.ID);

if (chkPhoto.Checked)
chkPhoto.Checked = false;
...
}
}

// As suggested in another forum, I tried this but when cancel is 
click,
it executed
//the GetSelectedPhotosForDeletion() method
function ConfirmDelete(szText)
{
var confirmed = confirm("Are you sure you want to delete the " +
szText + "?");

if(confirmed)
return true;
else
{

var allInputs = Form1.getElementsByTagName('INPUT'); //check 
all
input boxes

for ( var i=0; i<allInputs.length; i++ )
{
if ( allInputs.type ==
'checkbox'
)
{
if ( allInputs.checked)
allInputs.checked 
=
false;
}
}
//do the same for 'select' controls 
and
radio buttons
return false;
}
}


//This gets executed
protected void btnDelete_Click(object sender, EventArgs e)
{
GetSelectedPhotosForDeletion();//even clicking cancel in
confirm this gets executed..
}

Thanks in advanced..

den2005
 
B

Baski

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 said:
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 said:
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 said:
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.GetType(),
"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


:


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.


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:
Code:
<td id="mam" height="180">
<iframe id="NewsBody_rich"
src="includes/MsgBody.htm"
width="100%" height="100%"
onblur="fillTxt()" style="font-family:
Arial"></iframe>
</td>

//Javascript function to be executed
function setTxt(szText)
{
var State = new Object()
var aa;
NewsBody_rich.document.body.innerHTML = szText;
}

Question 2:
Code:
UserControl mentioned
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="AlbumDetailList.ascx.cs"
Inherits="usercontrols_AlbumDetailList"
%>
<asp:Panel ID="pnlMain" runat="server" Height="600px" Width="824px">
<table id="tblMain" width="824" border="0">
....
<tr>
<td>
<asp:Panel ID="pnlPhotos" runat="server" 
Height="100px"
Width="824px">
</asp:Panel>
</td>
</tr>
...
</table>
</asp:Panel>

Inside MasterPage:

<script language="javascript" type="text/javascript">
....
function ConfirmDelete(szText)
{
var confirmed = confirm("Are you sure you want to delete the 
" +
szText + "?");

if(confirmed)
return true;
else
return false;
}
....
</script>

//Add attributes to delete buttons
private void InitializeButtonAttributes()
{
btnDelete1.Attributes.Add("onclick", "JavaScript:return
ConfirmDelete('Image/s')");
btnDelete2.Attributes.Add("onclick", "JavaScript:return
ConfirmDelete('Image/s')");
}

I need to execute this method:
//Remove Checked in CheckBox
private void ReInitializeCheckbox()
{
foreach (Control ctrl in myPanel.Controls)
{
....
CheckBox chkPhoto = 
(CheckBox)ctrl.FindControl(ctrl.ID);

if (chkPhoto.Checked)
chkPhoto.Checked = false;
...
}
}

// As suggested in another forum, I tried this but when cancel is
click,
it executed
//the GetSelectedPhotosForDeletion() method
function ConfirmDelete(szText)
{
var confirmed = confirm("Are you sure you want to delete the 
" +
szText + "?");

if(confirmed)
return true;
else
{

var allInputs = Form1.getElementsByTagName('INPUT'); //check
all
input boxes

for ( var i=0; i<allInputs.length; i++ )
{
if ( allInputs.type ==
'checkbox'
)
{
if ( 
allInputs.checked)

allInputs.checked
=
false;
}
}
//do the same for 'select' 
controls
and
radio buttons
return false;
}
}


//This gets executed
protected void btnDelete_Click(object sender, EventArgs e)
{
GetSelectedPhotosForDeletion();//even clicking cancel 
in
confirm this gets executed..
}

Thanks in advanced..

den2005
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top