Webforms routing - populate hyperlink NavigateUrl with dynamic parameters - javascript

I'm using a linkbutton for this so I know that I can postback and perhaps redirect, however I'd prefer to do this directly using a hyperlink is possible.
I have a route setup with parameters:
href='<%$RouteUrl:RouteName=Apply, Amount=1234 %>'></a>
The issue I have is that I'm using jquery to update some textbox fields - so the user slides a slider, which updates a textbox. jQuery needn't be part of the equation because the user could also enter a value directly in the textbox.
What I want to achieve is that the amount param is dynamically inserted somehow into the the href value - almost like an embed block within an embed block. Is it possible?
Thanks in advance.

Related

Getting dropdown selected value on change using DOJO script

Hi I am working on DOJO website and I need to get the dropdown selected value without redirecting to another page using DOJO script or Plain javascript(No jquery, because dojo website not supporting Jquery).
Here is my scenerio
View account
View payment
address change
FAQ
You want the value selected from a drop down box but the act of selecting the value in the first place causes a redirect? You mean the values are coded as links? If so then you need to find the code where the value is used as a link and write some condition to get the value rather than let the click redirect.
If you just want the currently selected value then you need to find the same code, where it was processed as a link, and set a variable there that you can use for your purposes.

How to Retain text in Text box using Javascript?

I have A page for registering user Details and from this page I have an option for adding his Sate/Continent. After Adding Sate/Continent he can navigate to his previous page.. But At this time Already filled Data's are missing so that he can have to enter again this.. Is there any possibility to solve this using javascript??
Since you are navigating away from page you can either use some server side code to create a session and retain values between pages. Or you can use js cookies to retain the values like
document.cookie="continent=asia";

Restore dynamic Telerik RadWindows on next postback

I'm doing some ASP using Telerik.
On my page there are 2 buttons called Create Window and Postback. The Create Window button created a new RadWindow dynamically on it's click event (client-side) by using window.radopen(). The Postback button simply does a postback. My problem is that, the windows get lost after every postback. What can I do to make my RadWindows to remain opened after a postback, including its content and position.
If there is no built-in function to restore my dynamic RadWindows, please tell me how to save current windows content to manually load it on the next postback. I thought of using a Hidden control to save my RadWindow position and content, but how can I do that (it's content is a user control with plentiful textboxes, and i don't want my customer to re-type all the textboxes).
The RadWindows are generated via JavaScript when they are first shown. You can easily check this via your developer plugin of choice. Once you show them they create their wrapper div as a direct child of the form element. This means that they have no server-side rendering and thus cannot be persisted on the server across postbacks.
What you can do is use AJAX - have the button perform an AJAX request that will update the needed content of the page, but will leave the RadWindows out of the update. Check out this help article where they explain how to use AJAX with a RadWindow: http://www.telerik.com/help/aspnet-ajax/radwindow-ajaxifying.html.

Client-side JavaScript ViewState Update in asp .net forms

I have stumbled upon the issue when I need to retract html controls I've added client-side using JavaScript after the postback (due to server-side validation - this is not optional).
Please tell me if the way I'm trying to achieve this is cr*p and there's a better way of doing this.
basically, what I'm doing is cloning a textbox control for up to 10 times on the page when the user hits "Add" and storing entered values from each of those texboxes in a hidden field to read from in the code behind. This works fine, however, when the server side validation doesn't pass after postback, all those dynamically added (cloned) texboxes disappear, since ViewState knows nothing about them.
I am considering 2 possible solution, both of which seem hacky:
Rebuild all cloned textboxes on document onload() using stored values in the hidden field
wrap the form in ajax update panel and place the cloned texboxes outside of it, thus, not refreshing this part of the screen on postback
now, is it possible to somehow "update" ViewState to make it aware of all the html controls I've added using client-side script? Any better ideas? I'd like to achieve this with client-side script, therefore not considering cloning textboxes on server-side, sorry.
You cannot modify the ViewState on the client side. If you do, you will invalidate the viewstate and receive an error on the postback.
In your case you might want to consider using javascript and jQuery to render the text boxes on the document ready event with the values stored in your hidden field. I'd recommend taking a look at jQuery templating, particularly if you can store your data as JSON in the hidden field (http://weblogs.asp.net/scottgu/archive/2010/10/04/jquery-templates-data-link-and-globalization-accepted-as-official-jquery-plugins.aspx).

pager without javascript in asp.net

how to use Pager(GridView or ListView) with html link.
is that right that this code is not SEO friendly?
thanks.
You have two questions.
First:
You can implement a pager by using post-backs. Basically you will invoke a server call at each click of a link. And the server would reply with a new page of the dataset. But the asp.net controls submit the form using javascript. It looks like:
link text
So to not use the javascript at all, you could use a HTTP GET only method. This is just one way to do it.
So what you want generated is something that, it will pass to your server a page value using a query string parameter named 'page'.
You can handle that in your aspx page any way you see fit. But it needs to generate some thing like that.
page 2
In the page load of somepage.aspx you handle it.
protected void page_load(EventArgs e){
// check if the page parameter is set in the query string
if(Request.QueryString["page"] != null){
// page is the value of the requested page
var page = Request.QueryString["page"];
}
// bind you data to the control.
}
Then when binding the data to your GridView or ListView you filter the data based on the page requested.
#pre has a good answer for your first question.
Regarding your second about SEO and JavaScript:
JavaScript has to be used correctly. In other words, the html has to have the links and all of the pieces necessary to be read by a spider. If nav elements are injected via JavaScript then you can be assured that a spider will not see them.
You can certainly use JavaScript to change the styling, reposition the pager area or add other attributes but the base anchor tags with the appropriate href attributes have to be present.

Categories