The RadWindow is a client-side object – its UI is created when it is first shown and this is the point when the CSS and scripts are loaded as well. This means that it should be used on the client via JavaScript, yet it turns out that it is a very common scenario that the developer wishes to initiate the RadWindow’s showing from the code-behind.
The VisibleOnPageLoad property should not be used for this
purpose. It is a behavior property which will result in the RadWindow opening
every time the page is post back.
Quite often the VisibleOnPageLoad property gets set to true
while the intention is that the RadWindow should only show once. Doing so will
result in the RadWindow reopening if a postback is initiated from another
element from the page, which is rarely the desired behavior. Also, this
approach will not work in case this happens in an AJAX request and the
RadWindow is not included in the partial page update.
There are several ways to work around this:
1) Register a JavaScript function from the
server-side and do not use the VisibleOnPageLoad property, for example:
<
telerik:RadWindow
runat
=
"server"
ID
=
"RadWindow1"
NavigateUrl
=
"http://google.com/"
></
telerik:RadWindow
>
<
asp:Button
ID
=
"Button1"
Text
=
"open the RadWindow from the server"
runat
=
"server"
OnClick
=
"Button1_Click"
/>
protected
void
Button1_Click(
object
sender, EventArgs e)
{
//business logic goes here
string
script =
"function f(){$find(\""
+ RadWindow1.ClientID +
"\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
;
ScriptManager.RegisterStartupScript(Page, Page.GetType(),
"key"
, script,
true
);
}
Protected
Sub
Button1_Click(sender
As
Object
, e
As
System.EventArgs)
Handles
Button1.Click
'business logic goes here
Dim
script
As
String
=
"function f(){$find("
""
+ RadWindow1.ClientID +
""
").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
ScriptManager.RegisterStartupScript(Page, Page.
GetType
(),
"key"
, script,
True
)
End
Sub
TextBox tbFloat = new TextBox();
string fID = ID + "Value" + i2;
tbFloat
.ID = fID;
tbFloat
.Attributes.Add("name", fID);
tbFloat
.Text = Value;
c2.Controls.Add(tbFloat
);
Telerik.Web.UI.NumericTextBoxSetting radF = new Telerik.Web.UI.NumericTextBoxSetting();
radF.EmptyMessage = "";
//radF.DecimalDigits = ? ;
radF.Type = Telerik.Web.UI.NumericType.Number;
radF.Validation.IsRequired = false;
TargetInput fi = new TargetInput();
fi.ControlID = fID;
radF.TargetControls.Add(fi);
RadInputManager1.InputSettings.Add(radF);
radF.DecimalDigits = -1 ;
If
(expression.GroupByFields(0).FieldName =
"EngNameWithID"
)
Then
radGrdEngagments.GroupingSettings.ShowUnGroupButton =
False
Else
radGrdEngagments.GroupingSettings.ShowUnGroupButton =
True
End
If
protected
void
RadFileExplorer1_ItemCommand(
object
sender, Telerik.Web.UI.RadFileExplorerEventArgs e)
{
if
(e.Command ==
"UploadFile"
)
{
Telerik.Web.UI.RadFileExplorer explorer = sender
as
Telerik.Web.UI.RadFileExplorer;
Telerik.Web.UI.RadUpload upload = explorer.Upload;
//e.Path holds the file path
string
name = e.Path.Split(
new
char
[] {
'/'
}).Last();
// get the filename including extension ;
foreach
(Telerik.Web.UI.UploadedFile uploadedFile
in
upload.UploadedFiles)
{
if
(name.Equals(uploadedFile.GetName()))
{
string
fileName = uploadedFile.GetName();
string
imageSize = uploadedFile.GetFieldValue(
"imageSize"
);
// would like to pass imageSize to StoreFile method...
break
;
}
}
}
}