URL rewriting in ASP.NET 4.0 on radiobutton check event - asp.net

I am trying to change URL of website and need help for the same. The scenario is that I have a search engine for student search and have different criteria for refine search. By default I am showing all the student data on homepage and when we use search the result is displayed on the same page, so URL of the page does not change.
My search criteria are by date of join(1 month,2months,6months,1Yr) and state they belong from. I have added radio button for refine search, so on "OnCheckedChanged" event the data gets populated on the page. So now how do I change the URL so as to show something like, say I have website www.xyz.com and need to show www.xyz.com/bydate/1month or www.xyz.com/bystate/LA. Have googled many links but not able to understand how to start.
Below is snippet of my code
<asp:DataList ID="dlJoin" CssClass="slider" r RepeatColumns="1" RepeatDirection="Vertical" runat="server" OnItemDataBound="dlJoin_ItemDataBound">
<ItemTemplate>
<label style="text-align: left; margin-left:15px;">
<asp:RadioButton ID="rddlJoin" CssClass="radiobooking" Checked="false" AutoPostBack="true" OnCheckedChanged="rddlJoin_checkchanged" GroupName="rdGroupTag" runat="server" onKeyPress="return suppress(event);" /><%#Eval("Name")%>
</label>
<asp:Literal runat="server" Visible="false" ID="litdlJoin" Text='<%#Eval("Value")%>'></asp:Literal>
</ItemTemplate>
</asp:DataList>

I would do this with Javascript and not worry about redirecting on the server side(assuming that all your clients should have javascript). You can do a "pure" redirect by using something like
window.location.href = "http://xyz.com/bydate/1month";
This has equivalent behavior as to if you clicked on a link to that URL.
If you're wanting to use Ajax and make things be a bit nicer looking(and no full page loads) you can use a combination of # URL changes and using a tool like jQuery to easily load a div or some such from another URL

Related

Assign separate link to each repeater item in ASP .net

I was trying to develop a forum website (trying to mimic some of its features) and I am using Entity framework to get my data. I have to use repeater as my instructor asked me to do so.
I would be having something like this using repeater that gets data for "Forum Category" and "Sub-category" from 2 separate database tables:
Forum Category 1
Sub-Category 1
Sub-Category 2
Forum Category 2
Sub-Category 1
Sub-Category 2
Now, I would like, when clicked on those sub-category list to be directed to the page of their own using query string and that is what I am not being able to figure out at this time. When I assign a link to those sub-lists, since they are automatically generated all of them point to the page that I initially assign. I was wondering if there was someway to dynamically assign links for this scenario. I was thinking of using ENUM, but again how do I run a for loop there.
The code I have for the repeater is below:
<asp:Repeater ID="categoryRepeater" runat="server" OnItemDataBound="RepeaterDataBinding">
<ItemTemplate>
<asp:Label ID="categoryLabel" Text='<%#Eval("CatName") %>' runat ="server"
style="font-weight:bold;font-size:large" />
<br />
<asp:Repeater ID="forumRepeater" runat="server">
<ItemTemplate>
<%#Eval("ForumName")%><br/>
<%-- right up there. Instead of hardcoding "DesktopForum1.aspx?ForumID=" which makes all the links
to point to that page, I am trying to achieve a way to assign links to specific pages for each sub-list...
--%>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
I did try searching the forum, but could not come across with a problem that resembled my situation.
If you're able to get the sub-list page URL with the query that populates forumRepeater, this should work:
<a href='<%#Eval("ForumUrl")%>'><%#Eval("ForumName")%></a><br/>
Would you like to put some acnchor for each item?
It will look like that:
<a name="someAnchor"></a>
and Link will be as follows: www.mywebsite.com/blog/posts#someAnchor
For more details: http://www.echoecho.com/htmllinks08.htm
If it is still not good, you need to handle and process querystring values with Javascript

How do I make my website prompt the iphone's equivalent of a dropdown menu?

I have a website that uses the AjaxControlToolkit. I'm making some parallel iPhone-friendly pages for the site, and since Ajax isn't very good-looking in a mobile browser, I'm trying to phase it out. One such Ajax tool is the CalendarExtender, which I replaced with the iPhone's Date Picker using this method.
The second tool I need to replace is the AutoCompleteExtender. It functions as a simple dropdown menu when the user types text into a text box. The purpose is for searching functionality; I have a large list of contacts, and when the user starts to type in a name or company name the extender appears with a list of suggestions based on what the user typed in so far.
Here's what it looks like in Ajax:
<asp:TextBox ID="NameTextBox" runat="server" AutoComplete="off" AutoPostBack="True"
OnTextChanged="NameTextBox_TextChanged" Width="95%" Font-Size="Medium"></asp:TextBox>
<cc1:AutoCompleteExtender ID="NameTextBox_AutoCompleteExtender" runat="server" CompletionInterval="250"
CompletionListCssClass="autocomplete_completionListElement" CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
CompletionListItemCssClass="autocomplete_listItem" DelimiterCharacters="" Enabled="True"
MinimumPrefixLength="2" ServiceMethod="GetCompletionList" ServicePath="" TargetControlID="NameTextBox"
UseContextKey="True">
</cc1:AutoCompleteExtender>
What is a good way to replace this with either a common piece of iPhone UI (such as the UIPickerView), or a more general mobile-friendly piece of HTML?
I would use a standard HTML element to maintain user experience.
For the autocomplete part I would use some javascript or an jQuery plugin. You could also choose to use Autocomplete from jQuery UI: http://jqueryui.com/demos/autocomplete/.

Create a web page as 2 parts

I want to develop a registration form with 2 panels. One panel is personal information and another is address details. In these panels the user fills in all details of personal information and after completion of this, the user clicks on Add Address Details. If the user clicks on that, the second panel should be visible without page refresh. How can I accomplish this?
you would use javascript to append the append the second form to to the div of the first form. Or however you have it setup. So in jquery it would look something like this:
<script type="text/javascript">
$('#buttonid').click(function() {
$('#divid').append("<form><input />etc etc etc</form>");
});
</script>
You should use the ASP.NET Wizard control. It is the perfect tool for these scenarios. Scott Gu has a post with some links explaining how to use it. I recommend you look at it.There's a video linked that walks you through a full example.
I don't know, but hiding/showing panels based on certain conditions on the same page feels inelegant and hacky to me.
You should look into using an UpdatePanel. Within there you could place to Panels with different form information. Tie in a few button clicks and hide/show the different panels.
Edit with a simple example
<asp:ScriptManager ID="sm" runat="server"></asp:ScriptManager>
<asp:UpdatePanel id="upnl" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:Panel ID="pnl1" runat="server">
<!--personal info-->
<asp:Button ID="btn1" runat="server" Text="this button could validate personal info, hide pnl1 and show pnl2" />
</asp:Panel>
<asp:Panel ID="pn2" runat="server" Visible="false">
<!--address info-->
<asp:Button id="btn2" runat="server" Text="this button could validate address information and finally submit the form." />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>

Can I use update panels with jQTouch?

I am using ASP.NET controls to fill in HTML for my jQTouch application, but I am having trouble with my hrefs ceasing to function as intended on my search page. The jQuery function for my anchor class evidently does not get called; it simply links back to the default page, even though the link is built similarly on other pages without any problems.
This is where my links are breaking:
<form id ="form1" runat="server" class="form">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel runat="server" ID="up1">
<ContentTemplate>
<ul class="rounded">
<li><asp:TextBox ID="txtSearchString" runat="server" name="search-articles" placeholder="Search GROK"></asp:TextBox></li>
<li><asp:Button ID="btnSearch" runat="server" Text="Search" type="rounded" OnClick="btnSearch_Click"></asp:Button></li>
</ul>
<asp:Literal ID="litSearchResults" runat="server"></asp:Literal> <%--HTML for jQTouch inserted here--%>
</ContentTemplate>
</asp:UpdatePanel>
</form>
This is an example of the HTML generated by code behind.
<ul class="edgetoedge"><li class="sep">Found 101 articles</li><li>PAWS: How to Access the Sample Test Database</li><li>Mac OS X: Hardware Test</li><li>The JavaScript Test</li><li>PAWS: Emergency Text Message Test</li><li>Definition: remote digital loopback test</li><li>Definition: power-on self test</li><li>Definition: power-on self test</li><li>AVG 9.0 Free Edition: Setting Scan Process Priority</li><li>Microsoft Office 2007: Diagnostics</li><li>Moodle: Description of Aggregation Methods</li><li>AVG 9.0 Free Edition: How can I run the complete scan of whole computer?</li><li>LSU A-Z: Office of Assessment and Evaluation</li><li>Linux: sed Insert a Newline Into the RHS of a Substitution</li><li>Microsoft PowerPoint 2007: Narrating a Slide</li><li>Ubuntu: Deleting Undeletable Files In the Trash</li><li>Linux: Remove All Digits/ Input From Inputs</li><li>SQL: Create a MySQL DocDB Databse</li><li>Linux Gnome: Screens and Graphics</li><li>Linux Xfce: Adjust keyboard settings</li></ul>
jQTouch handles every other tag normally, it is just the anchors that have ceased to function as intended by being placed inside this form. Can I keep using update panels here or will it inevitably break? Is there a work-around? Or am I approaching the problem incorrectly?
Keep in mind I want to retain the AJAXical animations produced by jQTouch. If you find that I am unclear or you would like to see more code (I only included what I believe to be necessary), please let me know.
Bonus points if you can tell me how to get jQTouch to replace the ugly the ASP.NET button control with an iPhoney button. :)
I think you are going to have to do a ton of hacks to get ASP.Net working with jqtouch with update panels, as you are going to be fighting the JavaScript inserted by ASP.Net with the JavaScript that jqtouch inserts. In your example all your links are going to the same anchor (#article). To do this in a jQtouch kind of way, you would have all the the links going to '#' and handle the tap of the articleLinkClass and then adjust as you need to.
$('.articleLink').tap(function()
{
var id = $(this).val('id');
// Pseudo CODE HERE FOR Setting up the article based on id... E.g.
$.json(jsonServiceUrl, { article_id: id }, function(data)
{
$('#article data).html(data);
});
jQt.goTo('article'); // Display the article page...
});
The iPhoney buttons are created in jQtouch as 's with their class as "whiteButton", i.e.:
<a id="myTestButton" class="whiteButton">Test Button</a>
Hope this helps...

How do I develop an online survey application?

I want to develop application that contain number of question with independent radiobuttonlist which contain three option Yes, No, Unsure.
Daily visitors comes on the site & reply to the question. Also to show addition of the Yes, NO & Unsure in front of each question.
Please give me idea how to do such functionalty.
Regards,
Girish
Quickest and easiest way would be to piggy-back on an existing site.
http://www.polldaddy.com/ will allow you to embed polls in your own site
This is a very vague question and probably won't get much of an answer.
What technology do you want to use, .Net, Java. PHP etc, what resources do you have available?
Essentially you need some sort of database to store the questions and answers in and a front end web application built in whatever technology you decide on (as stated .net, Java or PHP are probably the most common).
Create a custom control that uses an Update Panel. Inside the update Panel you will have two PlaceHolders - 1 for your questions and 1 for your results. Hide the results placeholder by default. Once the radiobutton (OnSelectedIndexChanged) is selected, cause a postback and calculate the results. In the same Postback method, hide the Question placeholder and show the results placeholder with the calculated results.
Your page could look like this:
<UpdatePanel ID="upPanel" runat="server">
<ContentTemplate>
<asp:PlaceHolder ID="plcQuestion" runat="server">
Have you ever written asp.net code?
<asp:RadioButtonList ID="radList" AutoPostBack="true" OnSelectedIndexChanged="doStuff">
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
<asp:ListItem>Unsure</asp:ListItem>
</asp:RadioButtonList>
</asp:PLaceholder>
<asp:PlaceHolder ID="plcAnswers" runat="server" Visible="false">
Results:
Yes: <asp:Label ID="lblYesResults" runat="server" />
No: <asp:Label ID="lblNoResults" runat="server" />
Unsure: <asp:Label ID="lblUnsureResults" runat="server" />
</asp:PLaceholder>
</ContentTemplate>
</UpdatePanel>
Then, on your "doStuff" method, just save the results and populate whatever result display you are going for. Hope this helps!

Resources