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:
Question 2:
Thanks in advanced..
den2005
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