I dont know if this is possible or not but I was wondering if there is a way to change a message in the UpdateProgress when using Ajax. I tried put the message in a label and for some reason i cant do it that way so just wondering you can how to do that. Here is what I have below.
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
Logining In...
</ProgressTemplate>
</asp:UpdateProgress>
Just do like this
Page:
<asp:UpdateProgress ID="UpdateProgress1" runat="server" ClientIDMode="Static">
<ProgressTemplate>
<div id="overlay">
<asp:Label ID="lbl_wait" runat="server" clientIDMode="Static">Logining In...</asp:Label>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
Code:
(UpdateProgress1.FindControl("lbl_wait") as System.Web.UI.WebControls.Label).Text = "Logged In...";
Related
I am having a problem getting the values from the Radgrid auto generated Insert form.
I have my radgrid setup as shown in code shown below. I am only doing inserts and deletes and am using the edit form that is automatically opened when I click the add new record button.
<div id ="specialrequestGrid" class="container">
<div class="row">
<div class="col-md-12">
<telerik:RadAjaxPanel runat="server">
<telerik:RadGrid ID="SpecialRequests" runat="server" OnInsertCommand="SpecialRequests_InsertCommand"
OnUpdateCommand="SpecialRequests_UpdateCommand"
OnItemCommand="SpecialRequests_ItemCommand"
AllowAutomaticInserts="false"
AutoGenerateColumns="false"
OnNeedDataSource="SpecialRequests_NeedDataSource">
<MasterTableView CommandItemDisplay="Top" DataKeyNames="CaseId_FK, ReqId" Font-Size="Medium" NoMasterRecordsText="No Special Requests">
<CommandItemSettings AddNewRecordImageUrl="../Images/Add.png" />
<Columns>
<telerik:GridTemplateColumn HeaderText="Request Date" UniqueName="DateTemplateColumn">
<ItemTemplate>
<asp:Label ID="DateEditItemTemplate" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Date","{0:MM/dd/yyyy}") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadDatePicker ID="dpRideDate" runat="server" DateInput-DateFormat="MM/dd/yyyy" DbSelectedDate='<%# Bind("Date") %>' MinDate="1999/1/1" UniqueName="dpRideDate">
</telerik:RadDatePicker>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Requested By ID" UniqueName="RequestorTemplateColumn">
<ItemTemplate>
<asp:Label ID="Requestor" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "RequesterEID_FK") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<button id="btnRequestEID" type="button" class="btn" data-toggle="modal" data-target="#myModal" >--Please Select--</button>
<div>
<input type="text" Id="TxtSPRequestName" disabled />
</div>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Request Reason" UniqueName="RequestReason">
<ItemTemplate>
<asp:Label ID="ItemTemplatelblRequestReason" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Reason") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblRequestReason" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Reason") %>' Visible="false">
</asp:Label>
<asp:TextBox runat="server" ID="txtReason" Text='<%# DataBinder.Eval(Container.DataItem, "Reason") %>'></asp:TextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridCheckBoxColumn DataField="IsWOO" HeaderText="Is Out of Order" UniqueName="ISWOO"></telerik:GridCheckBoxColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
</telerik:RadAjaxPanel>
</div>
</div>
</div>
This is the screenshot of the auto generated form I get when I click the add new record
When I click the Insert link on the form I run this C# code
protected void SpecialRequests_InsertCommand(object sender, GridCommandEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
T_SpecialRequests t = new T_SpecialRequests();
t.IsWOO = (userControl.FindControl("IsWOO") as CheckBox).Checked;
}
Note the IsWOO is a control in the Radgrid that I did not show in the Screenshot. When I click the save link the Insert Function, shown above Runs but I get the following error:
Unhandled exception at line 1, column 123034 in http://localhost:52028/bundles/MsAjaxJs?v=c42ygB2U07n37m_Sfa8ZbLGVu4Rr2gsBo7MvUEnJeZ81
0x800a139e - JavaScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object.
The strange part is I use this same code in several other projects without any problems. The only difference is this is the first time I have used this auto generated form. I don't want to use the another type of control for this Radgrid due to such a small number of fields, only have 4 control.
I have spent several hours searching for an answer but just can't find the solution.
How can I get the values from this auto generated form?
You can use
t.IsWOO = (editedItem["ISWOO"].Controls[0] as CheckBox).Checked;
or
var newValues = new Dictionary<string, object>();
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
t.IsWOO = (bool)newValues["IsWOO"];
The first approach references the control by index because unfortunately it has no ID.
The second one is a bit verbose for just one property but I would surely prefer it if there were more properties.
While #Michal Nawrocik was correct I found that I still had some problems reading all of the controls in the Radgrid. I was able to track down the answer on the Telerik forum and found that you have to use different code based on the Column Type. I had 2 different type of columns.
the code below shows what I used to get all of the control values on the form
protected void SpecialRequests_InsertCommand(object sender, GridCommandEventArgs e)
{
try
{
using(LatentEntities db = new LatentEntities())
{
if (e.Item is GridEditableItem)
{
T_SpecialRequests T = new T_SpecialRequests();
var editableItem = ((GridEditableItem)e.Item);
RadDatePicker picker = (RadDatePicker)editableItem.FindControl("dpDate"); // in EditItem Template
DateTime dt = Convert.ToDateTime(picker.DbSelectedDate);
T.Date = dt;
TextBox Reason = (TextBox)editableItem.FindControl("txtReason"); //This Control was in an Edit Item Template
T.Reason = Reason.Text;
T.IsWOO = (editableItem["ISWOO"].Controls[0] as CheckBox).Checked; //In CheckBox Column
}
}
And if the control is in a Telerik:GridtboundColumn I used this code:
string strFirstName = (editableItem["firstname"].Controls[0] as TextBox).Text;
I have a telerik:RadCombobox in which user can type something to filter the recoreds.
If user type some word and tabout from taht control or clicked anywhere else on the form, basically onblur , its selectedindexedchanged event is fired that I don't want.
Please advise.
I have following html code on my page:
<telerik:RadComboBox ID="RCBGlobalSearch" runat="server" Height="190px" Width="330px"
EnableLoadOnDemand="true" ShowMoreResultsBox="true" EnableVirtualScrolling="true"
OnClientDropDownClosed="OnClientDropDownClosed" MarkFirstMatch="false" Filter="None"
HighlightTemplatedItems="true" Style="z-index: 9000" OnSelectedIndexChanged="RCBGlobalSearch_SelectedIndexChanged"
AutoPostBack="true" ToolTip="Enter or Select Issuer or User for Search">
<ExpandAnimation Type="none" />
<CollapseAnimation Type="none" />
<WebServiceSettings Path="~\GlobalSearchWebService.asmx" Method="GetGlobalSearchResult" />
</telerik:RadComboBox>
http://www.telerik.com/help/aspnet-ajax/combobox-onclienttextchange.html
- set_cancel lets you prevent the combobox from doing a postback (if AutoPostBack property is True), but doesn't let you prevent the text from changing.
<script language="javascript" type="text/javascript">
function OnClientTextChange(sender, eventArgs) {
eventArgs.set_cancel(true);
}
</script>
<telerik:RadComboBox onclienttextchange="OnClientTextChange"....
I have a web form in asp.net contains a RadAsyncfileupload and a RadBinaryImage inside an Asp Update Panel like following
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:UpdatePanel runat="server">
<ContentTemplate>
<telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server">
</telerik:RadAsyncUpload>
<telerik:RadBinaryImage ID ="RadBinaryImage1" runat ="server" Width= "100px" Height="100px"/>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
in code behind
protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
{
if (RadAsyncUpload1.UploadedFiles.Count == 1)
{
byte[] image;
long fileLength = RadAsyncUpload1.UploadedFiles[0].InputStream.Length;
image = new byte[fileLength];
RadAsyncUpload1.UploadedFiles[0].InputStream.Read(image, 0, image.Length);
RadBinaryImage1.DataValue = image;
}
}
but in runtime program controller does not fire RadAsyncUpload1_FileUploaded event
I have searched the Telerik forum and found that I should do something to script manager but I need some help on how to do it the reason is that in order to fire this event whole page should post back anyway some scripts can help me or any other ways!
mention that I need byte array of the image to save it in DB.
Thanks in advance
Saeed Soleimanifar
http://demos.telerik.com/aspnet-ajax/asyncupload/examples/persistuploadedfiles/defaultvb.aspx?#qsf-demo-source
I just added the same functionality by using this , if you find any problem let me know...
OR
Here is the part that does the magic
Page Source :
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
<script type="text/javascript">
function updatePictureAndInfo() {
__doPostBack('btnImgUpload', 'RadButton1Args');
}
</script>
</telerik:RadScriptBlock>
<telerik:RadBinaryImage runat="server" ID="imgBinaryPhoto" ImageUrl="~/Images/default-profile-pic.png"
Width="100px" Height="100px" ResizeMode="Fit" AlternateText="No picture available"
CssClass="preview"></telerik:RadBinaryImage>
<br />
<telerik:RadAsyncUpload ID="upldPhoto" runat="server" AllowedFileExtensions=".jpg,.png,.gif,jpeg,.tiff"
MaxFileInputsCount="1" MultipleFileSelection="Disabled">
</telerik:RadAsyncUpload>
<asp:Button ID="btnImgUpload" runat="server" Text="Upload" CssClass="button" OnClientClick="updatePictureAndInfo(); return false;" />
Code Behind:
Protected Sub FileUploaded() Handles upldPhoto.FileUploaded
Dim bitmapImage As Bitmap = ResizeImage(upldPhoto.UploadedFiles(0).InputStream)
Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream()
bitmapImage.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp)
imgBinaryPhoto.DataValue = stream.ToArray()
End Sub
ASP.NET 3.5 SP 1 / Visual Studio 2008 V 9.x RTM
I am trying to get a button inside a repeater inside an updatepanel to fire.
I't won't. I have tried adding a trigger outside the ContentTemplate and inside
the UpdatePanel to no avail:
<Triggers>
<asp:AsyncPostBackTrigger ControlID="BtnAddStatus" EventName="Click" />
</Triggers>
In fact, the AsyncPostBackTrigger's ControlID is always red and tells me "Cannot Resolve Symbol". This seems to be the case no matter where on the page I put the trigger.
I have read posts that have solved this problem by putting the button outside
of the UpdatePanel but then, graphically speaking, the button will not be in the
correct spot. It needs to be DIV with the ID of btnDiv.
So... how do I get the below button to fire?
<asp:Button ID="BtnAddStatus" CssClass="small button Detail" Text="Share" runat="server" />
ASPX code as follows:
<asp:Content ContentPlaceHolderID="ContentCenter" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Always" runat="server">
<ContentTemplate>
<asp:Label ID="lblMessage" runat="server"></asp:Label>
<asp:Repeater ID="repFilter" runat="server"
onitemcommand="RepFilterItemCommand">
<HeaderTemplate>
<div class="UIComposer_Box">
<span class="w">
<asp:TextBox class="input" ID="txtStatusUpdate" TextMode="MultiLine" Columns="60"
name="txtStatusUpdate" Style="overflow: hidden; height: 40px; color: rgb(51, 51, 51);"
runat="server"></asp:TextBox>
</span>
<br clear="all">
<div id="btnDiv" style="padding: 10px 5px; height: 30px;" align="left">
<span style="float: left;"> PHP, Codeigniter, JQuery, AJAX Programming +
Tutorials ( <a href="http://www.x.info" target="_blank" style="color: rgb(236, 9, 43);">
www.x.info</a> ) </span>
<asp:Button ID="BtnAddStatus" CssClass="small button Detail" Text="Share" runat="server" />
</div>
</div>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="Label1" Text='<%# ((Alert)Container.DataItem).Message %>' runat="server"></asp:Label>
</ItemTemplate>
<FooterTemplate>
<br class="clear" />
</FooterTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
AND MY PAGE LOAD CODE:
protected void Page_Load(object sender, EventArgs e)
{
_presenter = new DefaultPresenter();
_presenter.Init(this);
}
AND THE BtnStatusClick Method:
protected void BtnAddStatusClick(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
var su = new StatusUpdate
{
CreateDate = DateTime.Now,
AccountId = _userSession.CurrentUser.AccountId,
Status = "" //txtStatusUpdate.Text
};
_statusRepository.SaveStatusUpdate(su);
_alertService.AddStatusUpdateAlert(su);
_presenter = new DefaultPresenter();
_presenter.Init(this);
}
}
Thanks again.
Have you tried setting the click event in the button instead of handling it from the code behind?
<asp:Button OnClick="BtnAddStatusClick" ID="BtnAddStatus" CssClass="small button Detail" Text="Share" runat="server" />
I have an update panel which contains a GridView, inside which is a ButtonField. Whenever I press the button I see Firefox doing two POST's (via Firebug). One gets aborted right away, but does reach the server. This causes problems on my server side code as the command (a copy) gets executed twice.
IE6 and IE8 do not exhibit this behavior.
Anyone know what's causing this or what I can do about it?
I've managed to reproduce the problem to its bare minimum on this page:
<form id="form1" runat="server">
<asp:XmlDataSource ID="XmlDataSource1" runat="server">
<Data>
<bla>
<wibble wobble="1" />
</bla></Data>
</asp:XmlDataSource>
<asp:ScriptManager runat="server"></asp:ScriptManager>
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:Label runat="server" ID="Counter" Text="0"></asp:Label>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="XmlDataSource1" onrowcommand="GridView1_RowCommand">
<Columns>
<asp:BoundField DataField="wobble" HeaderText="wobble"
SortExpression="wobble" />
<asp:ButtonField HeaderText="wobble" CommandName="IncrementWobble"
SortExpression="wobble" ButtonType="Image" ImageUrl="icons/page_copy.png" Text="increment" />
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</form>
While making this small version, I noticed that the problem only occurs with ButtonType="Image" and not with ButtonType="Button".
For completeness, the event handler:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "IncrementWobble")
{
int count = Int32.Parse(Counter.Text) + 1;
Counter.Text = count.ToString();
}
}
From here, I found a workaround:
Replacing the ButtonField with a TemplateField containing an ImageButton works around the problem. Good enough for me, but still seems like a bug in either ASP .NET or FireFox.