I put an asp.net hiddenfield into one of my pages. I couldn't access it through javascript and when I went to view source, I couldn't find it in the page at all. Is there any obvious reason for this?
Here's the line with the hidden field:
<asp:HiddenField ID="HiddenEmailAddress" runat="server" Value="test" />
The problem was that the hiddenfield was placed in a table that was invisible at the time. Will self answer when system allows.
Your control is inside of another control that has it's visibility set to false, but you already knew that. :D
Related
Original Post
2 Additional Edits Below
I have a RADGrid on my page, but when the user clicks any of the controls within the grid, Page Forward/Back, Page Number, PageSize, Refresh, Checkbox Row Selector, etc... The entire page refreshes. I would like to have just the Grid itself refresh. I looked online, but I can't seem to find the information to make it all click.
I am using DNN 6, and I tried programmatically registering the RADAJAXManager (if missing, which it usually is) on the page. I saw people online referring to an EnableAJAX setting, but then later found that it was depreciated in the newer Telerik controls, so that option was ruled out. So then I tried programatically adding the AJAX Settings with the AddAjaxSetting()method. I have tried several variations of the parameters, but nothing happens. Obviously I am doing something wrong...I am looking entirely in the wrong place?
I tried surrounding my RADGrid with an AJAXPanel, but then the issue I had was that instead of the whole page "blinking" on a refresh, the RADGrid completely vanished, then re-appeared. I looked at several of the Demo's on the Telerik site, and I have no clue how they get their RADGrid to use the spinning circle refresh method for just the RADGrid.
I tried setting the page's "Support Partial Rendering" to true, but then what happens is that the whole page gray's out with the spinning circle. I just want to mimic the same behavior as shown on the Telerik Demo's.
Help!!! ::Frustrated::
Any clues or suggestions?
EDIT 4/18/2012 # 7:48PM EST
I am using the following code to create the RADAjaxManager (If missing) on the page where I place my custom user control.
Private Sub RegisterRADAjaxManager(ByVal p_objPage As Page)
'***************************************
' Register RAD AJAX Manager (If Missing)
'***************************************
Dim objRADAJAXManager As Telerik.Web.UI.RadAjaxManager = Telerik.Web.UI.RadAjaxManager.GetCurrent(p_objPage)
'***************************************
' If RADAJAXManager Is Missing, Add It
'***************************************
If (objRADAJAXManager Is Nothing) Then
objRADAJAXManager = New Telerik.Web.UI.RadAjaxManager
objRADAJAXManager.ID = "RADAJAXManager"
p_objPage.Form.Controls.Add(objRADAJAXManager)
End If
End Sub
I use the following code to add the Ajax Settings:
'***************************************
' Register RADGrid w/ RADAJAXManager
'***************************************
With TekkGrid.GetCurrentRADAJAXManager(Me.Page)
.AjaxSettings.AddAjaxSetting(Me.gridMain, Me.gridMain)
.AjaxSettings.AddAjaxSetting(Me.gridMain, Me.RADLoadingPanel)
End With
In my ASCX file I have:
<Telerik:RadGrid ID="gridMain" runat="server" />
<telerik:RadAjaxLoadingPanel ID="RADLoadingPanel" runat="server">
</telerik:RadAjaxLoadingPanel>
Am I missing anything?
EDIT 4/19/2012 # 8:56AM EST
EUREKA! I figured it out. My problem was such a silly one. I have an IF statement on my Page_Load() event that check if IsPostBack. I was only registering the AjaxSettings on the RADAjaxManager if IsPostPack = False. I didn't realize that the RADAjaxManager was being recreated on each PostBack, and therefor I was losing all my AjaxSettings, so I moved the method that did the AjaxSettings registration outside of the IF statement so it always run on every page load, and voilĂ ! It worked!
1) I tested the "Grouping" ability, and it works, however...when I drag a column, you don't "see" the collumn being dragged. All you see is a "crosshair" cursor as you are dragging the column. In the Demo's, when you start dragging a box with the column name inside it appears so you have a visual experience of the "drag/drop" feature. How do I get that same functionality? Anyone know?
If you mark your module control as "Supports Partial Rendering," DNN will wrap your module in a RadAjaxPanel. This is definitely the easiest way, and most compliant with what the framework provides/expects.
If you don't want the page to grey-out during the postbacks, you just need to adjust the style (probably at a portal/skin level, for consistency throughout the site). So, if your skin wraps the whole site with an ID of MySkin, you can use this CSS to change the style of the update progress display:
#MySkin .RadAjax .raTransp {display:none;}
UPDATE
To have the update progress indicator only display over the grid, try using the combination of RadAjaxManager and RadAjaxLoadingPanel as the demos do; something like:
<telerik:RadAjaxManager runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
I have a form that currently uses an control to submit a form. Everything works perfectly. So now the new requirement is for the "submit' button to be a link. Changing it to a LinkButton control, without changing a SINGLE other thing, breaks the validation.
There is a bit too much code to post in a SO question and I know there's a bit of a lack of detail here, but is there any reason why a LinkButton wouldn't fire ASP.NET validation the same way a Button control would? In theory, they should both operate exactly the same, no?
The current submit button:
<asp:Button ID="btnSubmit" TabIndex="9" Text="Send" ValidationGroup="Forward" runat="server" />
The new submit button:
<asp:LinkButton ID="btnSubmit" TabIndex="9" Text="Send" ValidationGroup="Forward" runat="server" />
The Link button should fires the validation the same way a normal button does, my concerns in your case would be the following:
make sure these is nothing in the server side code stopping this.
make sure in the javascript code there is nothing stopping the "
ASP.NET controls that fire validation has a property called CauseValidation
Be sure all controls should fire validation, has this property set to True
Add attribute CauseValidation="True" to your control but if you want to fire this at particular line at code behind you can use validate the form by the following code:
FormID.Validate();
I know this is old but it has never answered. Did your validator have a "controlTovalidate"? Currently it would appear as if the validator was not firing but in reality it is. It just does not have anything that it is 'watching'. Hope if anyone reaches this thread that this helps even if it is just a little bit.
I was unable to determine the cause of this issue but was able to solve it:
I set the CausesValidation="false" and added at the top of the onclick event this.Validate(linkButton.ValidationGroup) this allows the event to get to the code behind and validation to occur.
I'm working in ASP.NET and I have a CheckBoxList where I want one of the options to be basically like "Other: _." So I need to include a textbox where the user can fill in their own option. It doesn't seem like there's a way to include a textbox inside of a checkboxlist, however. What's the best way to make this work?
-UPDATE-
If using a separate textbox control, how do I position it so it will align correctly with the checkbox?
Make the textbox a separate control on the page, then in your codebehind, check to see if other is checked. If it is, pull the value of the textbox, and use that.
To answer the question in your edit: You'll have to play with the CSS of the page to get it positioned correctly. How you do it depends on the layout of the page, among other things. I recommend posting some of the HTML from your page in another question and ask about how to position them.
What #Kyle Trauberman said...
Make the textbox a separate control on
the page, then in your codebehind,
check to see if other is checked. If
it is, pull the value of the textbox,
and use that.
Plus use javascript to hide or gray out the option unless the checkbox is selected.
string test="";
<asp:CheckBoxList ID="chk_list" runat="server">
<asp:ListItem Value="00">xxxx</asp:ListItem>
</asp:CheckBoxList>
<asp:TextBox ID="other" runat="server"></asp:TextBox>
inside the for loop
if (chk_list.Items[i].Value == "00")
{
test +=chk_list.Items[i].Text + other.Text;
}
I use ASP.NET and have a label control on my page, which I fill with
the jQuery-Command
$('#<%= myLabel.ClientID %>').html(content);
.val() does not seem to work with this.
Somehow, I have Problems getting the content in code-behind. In the code, the myLabel.Text-Property is still empty.
If you want to display the value on the client and have it available on the page, you need an input that'll get sent to the code-behind when you POST like this:
$('#<%= myLabel.ClientID %>').html(content);
$('#<%= myInput.ClientID %>').val(content);
<asp:Label Id="myLabel" runat="server" />
<asp:HiddenField ID="myInput" runat="server" />
In the code-behind:
myInput.Value
I think your problem is that labels (rendered as span tags) are inherently read-only in the asp.net world. They're not meant to be used as 'input' controls, and as such changes to their HTML on the client-side are ignored on the server-side, where values are set based on ViewState.
To do what you are asking, you'd have to notify the server of the change as well, such as by using AJAX. The only issue here is ajax webmethods in your code behind are static, and because of this can't access the page's control set to change the .Text value.
In the end the easiest option is to make use of hidden fields as Nick said. These are technically 'input' controls and their values changed on the client-side are sent to the server as you desire. You'd just have to keep the label/span and hidden field/input synchronized on the client.
Hope this helps.
I have 3 different kinds of ajax popups that need to exist across my site. I was hoping that I could simply create a user control for each one and place the panel and modal popup extender inside each one but this doesn't seem to be working. Has anyone tried this before or do you have a recommendation as to how I can avoid duplicate code for each pop up on different pages? Thanks!
Ah I figured out my issue with the User Control I believe.
The ModalPopUpExtender requires the TargetID property to be set otherwise an error occurs. Since this is sitting in a UserControl I just created a dummy link button that doesn't do anything and I set the property visible to false.
<asp:LinkButton ID="lnkBlank" runat="server" Visible="false" />
<asp:Panel ID="plContainer" style="display: none;" runat="server">
Hello?
</asp:Panel>
<cc1:ModalPopupExtender ID="mpe" runat="server"
BehaviorID="test"
TargetControlID="lnkBlank"
PopupControlID="plContainer" />
Apparently it doesn't appreciate that and the moment I set the visible property to true it started working. Not sure what the reasoning is for a TargetID since, I would think, most pop ups could be called from multiple links about the page. Perhaps I'm still not entirely clear on how this control is supposed to be used.
One option would be to write the popups in a asp.net user control (a .ascx page) and include that on the pages you need the popups. Have a public method in the ascx page that will show the popup, and call it from the parent page when you need to. If you already have a script manager on the parent page, you can't have a second one in the ascx page, but other then that there shouldn't be anything that would stop this from working. Hope this helps!
edit: here's what my modal popup extender control looks like...
<cc1:ModalPopupExtender
ID="mpeClassroom"
BackgroundCssCLass="modalBackground"
runat="server"
CancelControlID="lbClose"
OnOkScript="onOk()"
TargetControlID="Button1"
PopupControlID="pnlClassroom">
</cc1:ModalPopupExtender>
in my code behind page, my method just calls mpeClassroom.Show();
The problem with hidden link as TrgetControlID is that; when u set its visibility as false, server doesn't render it as well. PopExtender then cannot find control on the page.
Instead of setting its visibility to false, try to apply a style with display:none. This should work !