I have a database that I need to turn into a list for a webpage. I have the data bound to a gridview in the page_load function of a behind code file. I was wondering how I could take my grid data and create a ul/li list with it. Here's my function so far:
protected void Page_Load(object sender, EventArgs e)
{
Service1 myService = new Service1();
//Use a gridview to store the table data before building the menu
GridView sites = new GridView();
sites.DataSource = myService.GetAllSites();
sites.DataBind();
foreach (GridViewRow siteRow in sites.Rows)
{
String itemName = siteRow.Cells[1].Text;
}
Also, does anyone know how to make a list expandable? So that clicking one list item will cause a div or something to open right below it, moving the list items down a bit to make room?
What you've described sounds very close to the asp.net TreeView control
http://msdn.microsoft.com/en-us/library/d4fz6xk2(v=vs.80).aspx
Adding to the tree:
treeView1.Nodes.Add(new TreeNode(site.Name));
A pretty easy to follow example here:
http://www.nullskull.com/q/10328363/treeview-in-aspnet-with-examples.aspx
Related
This is the syncronization popup (com.hybris.backoffice.widgets.syncpopup.SyncPopupController) used to synchronize catalogs . I want to modify this OOTB widget in order to add multiple selection instead of one (right now , you can only select one catalog at a time).
How can I achieve this ? I don't know how to extend backoffice widgets.
The Listbox you're trying to modify has an attribute called multiple. By default at initialization this is false. The widget lists (because there are 2 lists, one for stage->online and one for online->stage) doesn't have this attribute set to true when the widget is created. The initialize() method from the SyncPopupController only fill these lists with items but nothing more.
Now that you know the root of the problem, you can read this tutorial which explains you how you can extend a widget mot-a-mot. One solution could be extending the original controller and make your custom configuration in the initialize() method.
This could look like this:
public class ExtendedSyncPopupController extends SyncPopupController
{
public void initialize(Component component){
super.initialize(component);
super.getPullList().setMultiple(true);
//etc.
}
}
And after this, you can override the widget definition ( Overriding the Widget Definition chapter from the tutorial provided above ) and pass your custom controller class in <controller class="ExtendedSyncPopupController">.
Hi all I was designing web application in that i have two master pages Default.aspx and Addregistration.aspx in addregistration i stored the data in database using SQL and i display data in default page as a gridview and I made my column as hyperlink in grid view when I click that link it should go to addregistration page how I store the data with fields and text what I type.Below is the Css for column
Handle it by javascript. Your NavigateUrl is #, and add an onclick event, Or just use an input type button to make it easier
<asp:HyperLink ID="hlink" CssClass="control" runat="server" NavigateUrl='#' onclick="gotoRegistration(<%#Bind("ReferenceNo")%>)" Text='<%#Bind("ReferenceNo")%>'></asp:HyperLink>
try there to pass the ReferenceNo to the JS function, if Bind doesn't work, try Eval.
and your JS
<script>
function gotoRegistration(theRefNo)
{
theUrl = "~/AddRegistration.aspx?refNo="+ theRefNo
window.location = theUrl;
}
</script>
And then your Registration page read it from Query of the Request
Use the Page.PreviousPage Property to get data or access controls at Default.aspx from Addregistration.aspx
sample code in Addregistration.aspx:
protected void Page_Load(object sender, EventArgs e)
{
Page.PreviousPage.FindControl("hlink")
}
In my windows phone application one profile page is there.in this profile page profile,changepassword,orders and cash pivot items are there.
Whenever I click changepasswordbutton then page will navigate from mainpage to profile page always go to profile pivot item only.
I want to go to changepassword pivotitem. How will solve this problem? please help me....
private void changepassword_Click(object sender, RoutedEventArgs e)
{
Frame.Navigate(typeof(profile));
}
You can set the pivot control's SelectedIndex property to switch to a distinct pivot item within the page. For example, if changepassword is the third pivot item, you'd set
PivotControl.SelectedIndex = 2
If this shall be done directly after loading the page (e.g. because you just navigated to the page containing the pivot control), I'd run this code within the page's OnNavigatedTo method.
Already answered by stack overflow for this question
Question
Frame.Navigate(typeof(profile), 1);
In your profile page:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
MainPivot.SelectedIndex = (int) e.Parameter;
}
Hope this will help you..
I have a mainpage with a Button with some content. I want to open a second page or popup in witch i must have a longlistselector with X items in it. when i choose one of them i want to change the content of the button to the selected item.
I can make the main page and the second page i dont know how to send back the result to the first page. ?
if you are using "MVVM Light" library then you can use Messenger service Like this....
in second page after selection is changed send a message
Messenger.Default.Send<type>(message,token);
and then in the consructor of page 1 viewmodel
Messenger.Default.Register<type>(this,token,Method);
here token should be same as sender token....
then
void Method(type message)
{
button.content = message;
}
Use Popup to show your LongListSelector ,and when set popupElement.IsOpen=false; the set Button Content same as required,
If you wish to change content as selected list then use popupElement.IsOpen=false; on selection change method and get selected item there.
Remember use selection change method on page not inside popup child class.
If you are using a separate page to show the longlistselector, then you could try something like this.
//in long list page,
Void longlist_SelectionChanged()
{
PhoneApplicationService.Current.State["key"] = longlist.selecteditem;
NavigationService.GoBack();
}
//in your main page where the selected data has to be displayed..
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
if(PhoneApplicationService.Current.State.ContainsKey("key"))
{
Button.Content = PhoneApplicationService.Current.State["key"];
}
}
I´m evaluating GWT as one of the alternatives to develop AJAX applications for my future projects. Untill now it is as good as it gets, but now I´m stuck looking for a way to capture a click on a tag inside HTML widget. I want to write links inside the HTML but I want to process the clicks in my application, withou reloading the page. Imagine I have the following HTML:
<p>GWT is a great tool and I think it will be my preferred tool to develop web applications. To check out my samples <a id='mylink'>click here</a></p>
I want to capture the click over the "click here" part of the text. What I´ve done so far is to try to attach the id "mylink" to some sort of clickable widget and process the click with a ClickHandler for that widget, but nothing is working.
Is there a way to do that? By the way, I know very little about Javascript.
Thank you in advance.
You can also do it like this:
Anchor.wrap(DOM.getElementById("mylink")).addClickHandler(yourClickHandler);
DOM class is com.google.gwt.user.client.DOM.
Edit after comments.
OK, the method works for elements out of GWT widgets (element comes with HTML file). If you need to generate it in GWT code then you can add link element separately. But it won't work if your content goes for instance from DB.
HTMLPanel html = new HTMLPanel("GWT is a great tool and I think it will be my preferred tool to develop web applications. To check out my samples ");`
Anchor a = new Anchor("click here");
a.addClickHandler(yourClickHandler);
html.add(a);
If it is fully dynamic I don't have an idea at this point. I was trying with HTML() widget, where you can plug your click handler, but I couldn't find a right way to determine whether the click was in A element. Strange.
The final approach (I hope)
This one should work finally. And I think this is the way it should be done, especially that it allows any structure of the HTML. The are two ways:
1. Convert links within HTMLPanel
This one will find all A elements and convert them into Anchors. It ignores href attribute, but you can add it easily :)
HTMLPanel html = new HTMLPanel("<p>Multilink example 2: <a>link1</a> and <a>link2</a></p>");
NodeList<Element> anchors = html.getElement().getElementsByTagName("a");
for ( int i = 0 ; i < anchors.getLength() ; i++ ) {
Element a = anchors.getItem(i);
Anchor link = new Anchor(a.getInnerHTML());
link.addClickHandler(...);
html.addAndReplaceElement(link, a);
}
2. Insert links into prepared spots
Just insert placeholders, where the widgets should be inserted. You could also use the addAndReplaceElement() method but with string ID.
Anchor a1 = new Anchor("a1");
a1.addClickHandler(...);
Anchor a2 = new Anchor("a2");
a2.addClickHandler(...);
HTMLPanel html = new HTMLPanel("<p>Multilink example: <span id='a1'></span> and <span id='a2'></span></p>");
html.add(a1, "a1");
html.add(a2, "a2");
Try something like this.
For your web page, you can use UiBinder:
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:HTMLPanel ui:field="panel">
<p>
GWT is a great tool and I think it will be my preferred tool to
develop web applications. To check out my samples
<g:Anchor ui:field="myLink" text="click here" />
</p>
</g:HTMLPanel>
</ui:UiBinder>
Notice that I've replaced your tag with an Anchor widget. There is also a Hyperlink widget, which has hooks into the history system.
The Anchor has a id of "myLink", which is used in the GWT companion to the XML file:
public class So extends Composite {
private static SoUiBinder uiBinder = GWT.create(SoUiBinder.class);
interface SoUiBinder extends UiBinder<Widget, So> {
}
#UiField
Anchor myLink;
public So() {
initWidget(uiBinder.createAndBindUi(this));
myLink.addClickHandler(new ClickHandler() {
#Override
public void onClick(ClickEvent event) {
GWT.log("caught the click");
}
});
}
}
I've added a ClickHandler that captures and acts on the click event.
The main program is simple:
public class SOverflow implements EntryPoint {
public void onModuleLoad() {
RootLayoutPanel.get().add(new So());
}
}
Run this after and a webpage appears with the text and hyperlink. Click on it and "caught the click" appears in the console window (I'm using Eclipse).
I hope this is what you're after. If not exactly, it might at least give you some ideas of how to attack your problem.