RadAjaxLoadingPanel does not works with DNN - c#

I have a dnn site, which has a label and an imagebutton, clicking on which replaces the label with textbox and user can enter their text, once submitted the label will be updated with this text. Now clicking on the imagebutton causes the page to postback, i don't want a postback for this, hence i have placed telerik RadAjaxLoadingPanel control, so the cool loading div gets displayed while processing is going on, but for some reason it's not working, It always throws below error:
Please, see whether wrapping the code block, generating the exception, within RadCodeBlock resolves the error.
Below is the markup of my page: (I tried the wrapping the code with RadScriptBlock and RadCodeBlock, in both case it throws same error as above)
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">
</telerik:RadAjaxLoadingPanel>
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
<a class="subscribetoday" href="#">
<strong>Subscribe Today!</strong> <asp:Label ID="lblsubscribemsg" runat="server" Text="12 issues for $14.95"></asp:Label>
<asp:ImageButton ID="imgEditSubscribe" runat="server"
OnClick="imgEditSubscribe_Click" ToolTip='Edit' ImageUrl="~/images/edit.gif" AlternateText='Edit' Visible="false" />
<div id="editsubscribe" runat="server" visible="false">
<asp:TextBox ID="txtSubscribe" runat="server"></asp:TextBox> <asp:ImageButton ID="imgSave" runat="server"
OnClick="imgSave_Click" OnClientClick="return validateSubscribeNote();" ToolTip='Save' ImageUrl="~/images/save.gif" AlternateText='Save' /> <asp:ImageButton ID="imgCancel" runat="server"
OnClick="imgCancel_Click" ToolTip='Cancel' ImageUrl="~/images/cancel.gif" AlternateText='Cancel' />
</div>
<img src="img/prosound-subscribe.png" alt="Subscribe Today!">
</a>
</telerik:RadScriptBlock>
</telerik:RadAjaxPanel>
Can anyone tell me where i am going wrong with this.

The problem is with other server code blocks on the page (<%=%> for example, generally - <% ... %>), not with this concrete piece of code you are trying to AJAX-enable. You can read more here: http://docs.telerik.com/devtools/aspnet-ajax/controls/ajax/radcodeblock-and-radscriptblock
So, you should find the place where those code blocks are used and wrap THEM in a RadCodeBlock controls. It is often scripts that reference controls, e.g.:
<telerik:RadCodeBlock runat="server" ID="RadCodeBlock1">
<script>
function getReference() {
return $find("<%=someControl.ClientID%>");
}
</script>
</telerik:RadCodeBlock>
With DNN, however, I cannot say where these may originate.
Thus, your other option is to use an <asp:UpdatePanel> control to get AJAX requests instead of full postbacks. The native AJAX toolset also offers the <asp:UpdateProgress> control that you can use instead of RadAjaxPanel.

Related

Radio button not visible in ASP.NET page

ASP.NET radio button is not visible in my page. I am using it inside ASP.NET ListView. I tried putting the radio button inside ASP.NET update panel content template as well. Please tell me what has gone wrong?
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:ListView ID="FraudCheckList_listView" runat="server">
<ItemTemplate>
<p class="fraud-step-title"><%#Eval("question")%></p>
<div class="row">
<asp:RadioButton
runat="server"
class="radio-inline col"
GroupName="govt"
Text="Low Risk"
></asp:RadioButton>
<asp:RadioButton
runat="server"
GroupName='govt'
Text="Medium Risk"
></asp:RadioButton>
<asp:RadioButton
runat="server"
GroupName='govt'
Text="High Risk"
></asp:RadioButton>
</div>
</ItemTemplate>
</asp:ListView>
</ContentTemplate>
</asp:UpdatePanel>
Since you haven't shared how your code looks like, i am just assuming certain things. Just see if you have done this or not.
void Button_Click(object sender, System.EventArgs e){RadioButton.Visible=false;}
If incase its true or something your radiobutton will not be visible. In your case it must be hidden. So, make the variable of visible as **false ** So you can just change your code to this and try it out.
This you have to do it in your main code. not in your html code.
Thank You!

Modal Popup not firing in C#

I have been trying to get a Modal Popup to work for the last few months. I try and try, and after a while I just give up and find another way to work around it. I am very new to programming and have been doing some helpful things for my department, but in order to make these things viable alternatives I need to get more functionality out of them.
I want to be able to update a row in my SQL server, but the gridview is pulling data from a View, so the built in edit options won't work for me. I was hoping to be able to have a Modal Popup appear on the screen so that I can have the user put the data in and it will build the proper SQL statement to update the row.
I can't even get a Modal Popup with a single line of text to 'popup' though.
At the top of the page I have this:
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
Then in my main div I have this:
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat=server"></cc1:ToolkitScriptManager>
Then down in the body I have this:
<asp:Button ID="btnTest" runat="server" Text="Test" />
<cc1:ModalPopExtender ID="mp1" runat="server" PopupcontrolID='pnlEdit" TargetControlID=btnTest" OkControlID="btnSubmit" CancelControlID="btnClose" BackroundCssClass="modalBackground" ></cc1:ModalPopupExtender>
<asp:Panel ID="pnlEdit" runat="server" style="display:none">
<div class="modalPopup>
<p>Text goes here.</p>
<asp:Button ID="btnSubmit" runat="sever" Text="Submit" />
<asp:Button ID="btnClose" runat="sever" Text="Close" />
</div>
</asp:Panel>
Code Behind currently has nothing for this. I have tried the same code with the variation of giving the btnTest an OnClick that does mp1.Show();. And also tried adding a "dummy" TargetControlID that is rendered but not shown in order to use the Code Behind to fire.
Every variation produces the same results. The "Test" button is clicked and then nothing happens. It appears that the page is reloaded. What am I missing here?
Please take a look at this Solution

send ASP.Net Control Id To a JavaScript Function

I have 2 views. The last control on view1 is txtName & the first control on view2 is txtAge. Need to change the focus from txtName to txtAge on TAB press, but I fail to acheive this.
ASPX:
<asp:Multiview ID ="multiview1" runat="server" ActiveViewIndex="0">
<asp:view ID="view1" runat="server">
<asp:Textbox id="txtName" runat="server"
onfocusout="SetFocus('<%=txtAge.ClientId%>');"></asp:TextBox>
</asp:view>
<asp:view ID ="view2" runat="server">
<asp:Textbox id="txtAge" runat="server" ></asp:TextBox>
</asp:view>
</asp:Multiview>
JS:
function SetFocus(controlId){
/*alert(controlId);*/
document.getElementById(controlId).focus();
}
When I check the alert, it shows <%=txtAge.ClientId%> in the popup. Where is this going wrong.
Here is my new finding:
This code works well when the target control is in the same view, but when it is in another view, then it doesnt. So I think, something else should also be done to change the view first and then worry about the focus:
<asp:Textbox id="txtName" runat="server"
onfocusout="SetFocus();"></asp:TextBox>
function SetFocus(){
document.getElementById('<%=txtEmail.ClientID%>').focus();
/* txtEmail is in the same view 'view1' as in txtName */
}
You can try setting it in server-side code:
txtName.Attributes["onfocusout"] = String.Format("SetFocus('{0}');", txtAge.ClientId);
Perhaps it is sufficient to use tabindex
http://msdn.microsoft.com/en-us/library/ms178231%28v=vs.100%29.aspx
that uses build in features rather then javascript.
if you use asp.net 4.x you can use clientidmode=static
http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientidmode.aspx
<asp:Multiview ID ="multiview1" runat="server" ActiveViewIndex="0">
<asp:view ID="view1" runat="server">
<!-- other controls -->
<asp:Textbox id="txtName" runat="server" TabIndex="1"/>
</asp:view>
<asp:view ID ="view2" runat="server">
<asp:Textbox id="txtAge" runat="server" TabIndex="2"/>
<!-- other controls -->
</asp:view>
</asp:Multiview>
edit
if you do not mind using jQuery. You can wrap a div around <asp:View.. and then do something like:
$("div.view input:last-child").on("change", function(){
$(this).parent().next().find("input:first-child").focus();
});
please keep in mind that this is pseudo code. It is just an idea.
Try this and see if it's any better.
<asp:Textbox id="txtName" runat="server"
onfocusout='<%= String.Format("SetFocus(\"{0}\");", txtAge.ClientId) %>'></asp:TextBox>
It is not possible to set an attribute using an inline block in that situation... as you can see you are getting the literal <%=txtAge.ClientId%> text, and you are not getting the processed value that you are expecting.
You have two obvious solutions...
The first one (which Yuriy has already given you in his answer) is to set it from the code behind...
txtName.Attributes["onfocusout"] = String.Format("SetFocus('{0}');",
txtAge.ClientId);
(Disclaimer, I don't know what the MultiView is, as I've never used it, so I'm not 100% sure the 2nd option below will actually work in your scenario. Also, it is untested code.)
The other is to use what Murali provides in his answer, but with additional manipulation...
<asp:Textbox id="txtName" runat="server" onfocusout="SetFocus(this);" />
function SetFocus(nameCtrl) {
var ageId = nameCtrl.id.replace(/txtName/,"txtAge");
var ageCtrl = document.getElementById(ageId);
ageCtrl.focus();
}
Change line onfocusout="SetFocus('<%=txtAge.ClientId%>');"></asp:TextBox>
as onfocusout="SetFocus('txtAge');"></asp:TextBox>
You don't need to send ClientId

Invoke AJAX HoverMenuExtender from Javascript in .NET

In my c# web app,
I'm trying to invoke an Ajax HoverMenuExtender from Javascript, rather than from hovering over an assigned control.
If I set the TargetControlID of the HoverMenuExtender to a control on my page and hover the mouse over it, the hover menu displays, however, I cannot get it to display by manually invoking it with javascript.
The Javascript I'm currently trying:
popup = $("body").find('HME1');
popup.show();
//popup._popupBehavior.show();
I've stepped through the code so I'm sure popup.show() is being called. But it seems like nothing happens. It seems like .Show isn't really what we want to do, but instead we need to "Invoke" the AjaxExtender somehow.
The HoverMenuExtender:
<cc1:HoverMenuExtender ID="HME1" runat="server" BehaviorID="HME1" TargetControlID="dummyLink" PopupPosition="Top" PopupControlID="PopupMenu"></cc1:HoverMenuExtender>
A dummy link i'm assigning the control ID to:
dummy
The panel i'm trying to display:
<asp:Panel CssClass="popupMenu" ID="PopupMenu"
runat="server">
<asp:LinkButton ID="article" runat="server"
CommandName="Edit" Text="Edit" />
<br />
<asp:LinkButton ID="LinkButton2" runat="server"
CommandName="Delete" Text="Delete" />
</asp:Panel>
Use the following code:
$find("BehaviourID")._popupBehavior.show();

Asp.Net popup error message

Is there a way I can display an error message in a popup box? I'm using Asp.Net (C#), and on our webpage, if an order goes throug incorrectly we display an error message. Now, we would like to be able to do so using some sort of pop-up method (maybe Ajax?) - it should be able to take a string value to display the error message.
For a simple approach, you can have a script block that contains alert("your error message"). If you want the popup to be styled as the rest of your website then you could render your error message into a div element and use a jQuery dialog to display it as a modal dialog within your page.
I have used Ajax to accomplish this myself.
Using the ModalPopupExtender and setting the PopupControlID to an Asp Panel, I usually put this into a User Control so it can be easily used through a website.
However below is a snippet of the asp.net code
<div class="modalPopupAlign">
<asp:LinkButton ID="lnkConfirm" Style="display: none;" CausesValidation="false" runat="server" PostBackUrl="#">Confirm</asp:LinkButton>
<ajax:ModalPopupExtender ID="lnkConfirm_ModalPopupExtender" runat="server" TargetControlID="lnkConfirm" PopupControlID="pnlConfirmation" BackgroundCssClass="modalBackground" DropShadow="true" RepositionMode="None">
</ajax:ModalPopupExtender>
<div id="pnlConfirmation" class="modalPopup" style="display: none;">
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="modalPopupContainerAlign">
<div>
<asp:Image ID="imgIcon" CssClass="modalPopupImage" runat="server" />
<asp:Label ID="lblMessage" CssClass="modalPopupMessage" runat="server"></asp:Label>
<div class="modalPopupTextbox"><asp:TextBox ID="txtValue" Width="200px" MaxLength="100" Visible="false" runat="server"></asp:TextBox></div>
<asp:Button ID="btnAction" runat="server" CausesValidation="false" CssClass="defaultButton" Text="OK" />
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
It does take some time to get it working properly as I have had a few errors with the script manager, which I currently have setup in a master page.
Just might give you a direction to head for, and the CSS can help shape and colour the message box.
Although this is a complex way in some respect but has many uses.
You can do this with simple javascript like this...
alert("my error message");
Here is more info on using javascript

Categories

Resources