how to assign a radwindow property value from a public variable in page code? - asp.net

I have a radwindow and I'm trying to do this
<telerik:RadWindow ID="winQuote" runat="server" NavigateUrl="popupQuote.aspx?serie=<%= strSerie %>" Behaviors="Resize, Close, Maximize, Move">
When I get the value of the property serie using codebehind or javascript, it returns: serie=<%= strSerie %>.
It is not parsing the <%= serie%> tag, it is using it as if it were text, any ideas my friends?
Thanks

Just set it in the code-behind.
If you need such functionality on the client use JavaScript - see the RadWinddow client-side API: http://www.telerik.com/help/aspnet-ajax/window-programming-radwindow-methods.html and the setUrl() method that can be called after showing it.

Related

Data binding simple variable not working

This is the page code for the control:
<asp:TextBox id="someID" maxlength="10" columns="10" runat="server" Text="<%# work %>" />
This is how I set up and populate the variable before page is rendered, it is in the code behind, I have tried I think all the variations available for the variable declaration, e.g. public, shared, protected, etc.:
Public work As String
work = "987654321"
The textbox always comes up blank. referred to this ms kb page for how this work and it has a specific example.
However, it didn't explain anywhere if there is some special way of declaring the variables used in the binding or some special way to set the value of the variable, or is there something needed to allow the <%# syntax to work?
Binding doesn't happen automatically. You have to call DataBind() either from Page control or the text control. Try put it in Page_Load() method.

Binding custom class property of an ASP.NET control from ASCX markup

I have an ASCX that inherits from a WebControl that has a 'CustomConfiguration' property of type CollectionConfigurationItem. This configuration gets set elsewhere in the code, so by the time it gets to the ASCX it is set up to how I wish to use the data. At this point I'd like to render out another control using this configuration, like so:
<modules:DataModule runat="server" CustomConfiguration="<%# Model.CategoryListConfiguration %>" />
However, breaking into DataModule always results in 'CustomConfiguration' being null, which is the default value for the property. I've tried adding a Bindable attribute to the property but to no avail, and when I set an EventHandler for the DataBinding event on the DataModule it doesn't even get called.
How can I set this custom-class-typed property from the markup or, failing that what's the second-best method of getting this to work? Thanks for any light you can shed!
When you use the <%# %> syntax, it doesn't get executed until you databind the control. Try calling:
yourDataModuleID.DataBind();
e.g. from your Page_Init method.

How to fill a Label.Text - Property via jQuery

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.

asp.net button use javascript return function

I have an asp:button control and am using the "CommandName" and "CommandArgument" parameters in the .aspx file. The CommandName is found with <%# Eval("Name") %>, but the CommandArgument has to be found via a javascript function. However, I'm not quite sure how to do this inline. The function returns a number (integer), which is to be used as the value of the CommandArgument. Is it possible to do this?
Thanks
EDITED TO ADD CODE
I've added an example code (don't have access to the real code atm). However, basically, the CommandArgument should be the value returned by the function CalculateLength().
function CalculateLength(a,b) {
return a*b;
}
<asp:Button ID="btnUpdate" runat="server" Text="Update" CommandName=<%# Eval("Name") %> CommandArgument= ??? //Should be result of CalculateLength(a,b).
I am not sure how you are going to get the javascript to work because the aspx code is running server side and building the output for your button. By the time the javascript runs the page code has already been built and the button's html and attached javascript as well.
Is there anyway to calculate the function server side and then just do:
CommandArgument="<%= CalculateLengthServerSide() %>"
You don't need to just use the data your binding to, you can call any server side function.
Edit: Try switching your label that stores the quantity to a textbox and making it read only so uses will not mess with it. After the button is clicked, you should be able to find the textbox control and read out the posted value.

How to get value in a textbox that is readonly

I have a textbox.In its onclick iam calling a javascript fn to call calendar.Texbox is readonly. Clicking on textbox calendar is coming and value is showing in textbox. But on clicking submit button where I have written code to save, there i am not getting value in textbox. What may be the reason for that?
I suspect that your text box has the disabled attribute instead of readonly which prevents it from posting its value to the server.
I had this problem too, there is a really simple workaround
Instead of making the textbox ReadOnly using properties option. Do it thru the code behind adding this code:
YourTextBox.Attributes.Add("readonly", "readonly");
You can get the value by using
Request.Form[YourTextBox.UniqueID]
I'm guessing the textbox is disabled so that people have to use the calendar control to enter a date? The textbox is just for showing the selected date?
If you want the textbox to stay readonly (i.e. disabled client-side), have a hidden input that has the value you want to handle on the server is the way to go probably. So add an additional input for to the page. Use
<asp:HiddenField ... runat="server" />
So the client-side code that updates your readonly textbox will also update your hidden input.
if readonly property is true, its not break your .cs call. you can use this as always:
here are your inputs:
<asp:TextBox ID="txtBraid" runat="server" Text="Im sooo readonly" ReadOnly="True"></asp:TextBox>
<asp:Label ID="lblBraid" runat="server" Text="Im gonna change, i promise"></asp:Label>
on .cs page put these to onClick function or something:
lblBraid.Text = txtBraid.Text;

Resources