I have a JTable with multiple pages, and I'd like to be able to save the page the user is on in a session variable and automatically move the table to that page when they come back to it. Is there a way to change the page the JTable is on when it loads?
Looking through the code it does not appear there are any public methods to alter the page number, however you can do this as a workaround:
var pageNumberToChangeTo = 3;
$("#IDofMyTable").find(".jtable-goto-page select").first().val(pageNumberToChangeTo).trigger("change")
Related
What i've got is a Page1.aspx file, on this page i set some check boxes, some drop down values (a search filter page) that post back.
The search page returns to me a list of records (based on what was selected in the search section of this page).
Each record has a link to a "Details.aspx" page
on Details.aspx page i am able to modify values of the record, once done, i would like to get back to Page1.aspx but have Page1.aspx page in the same state that i left it.
By this i mean, i want the filters to be set as they were before the user navigated to the Details.aspx page
How can i do this?
i can not use history.back or history.go(-1)
Here is one way to do it: Put everything in a Session.
Load all the page1.aspx stuff into a class object, then add it to a Session (obviously before you go to the next page). Then when you go back check if that session exists, if it does, load the page using that class.
var myClass = new MyPage1Save
{
// load all the things you want saved
}
Session["Page1"] = myClass;
I am trying to Session over my Label.Text in the first .aspx page to another Label in the second .aspx page. I retrieve my value from the database and place them in the first Label.Text and want to Session this Label (Which i got the text from the database) to another page linked to the first page. I use this method is because i have a detailed products page (My first .aspx page) which consists of many products and when user click a particular product, it's product name have to be displayed in the second page of the .aspx . My problem here is that when i Session over the Label's text on the first page, the value does not pass over to another page.
My first page's .cs code (code behind):
Session["productName"] = productName.Text;
Response.Redirect("products2.aspx");
My second page's .cs code (code behind - I place this code in page load)
if (Session["productName"] != null)
productName.Text = Session["productName"].ToString();
Have i gone wrong anywhere?
Inorder to make the session not to be expired for a long time, you should follow two steps.
Keep a continous eye on the Session Timeout.
Redirect the session when its about to expire.
The Base Page for Detecting Sessions will explain you every thing you need to do, please refer it once.
your code is totally right..
but my question is are you using ispostback in your page load??
if not then use it like this..because of postback sometimes you can't get values.
then put your code if is not postback
page_load()
{
if(ispostback)
{
}
else
{
//put your code here
}
}
I have a list of 10 hyperlink on default1.apx. On selecting any hyperlink it redirects to another page and all hyperlinks redirects to the same page default2.aspx. But how can i now which hyperlink is clicked from 10 hyperlinks list in asp.net using C#.
There are a couple of ways, all depending on how you're doing your redirect.
I'm guessing you're using Response.Redirect(), which means you must be raising a server side event when clicking. In this case all you need to do is check the sender argument which will give you details of which control was clicked.
Another way is to append the controls' name onto the URL in a GET request. So that each link is slightly different. For example link one could point to default2.aspx?linkthatwasclicked='link1' where you can substiute link1 accordingly, this value can then be retreived on default2.aspx through the Request.QueryString object.
m.edmondson has got it, another way I've seen is having a "hyperlink.aspx" page which then requests an id:
Link 1
then in the hyperlink.aspx code:
int id = int.Parse(Request.QueryString["id"].ToString());
switch(id)
{
case 1:
// Add a count to a table maybe
// Get the url from the DB here...
string url = GetUrlById(id);
Response.Redirect(url);
break;
}
In ASP.NET, I have a master page, and five other pages which are under master page.
In all five pages, I need to implement a button, after clicking it, will generate different download results.
My original implementation is, in all five page, will all have a "Button", so in code behind will have corresponding event method to generate the download.
But my approach, will have duplicated html compoents.
Is there a way I can define the download button in my master page, when clicking button in different page, event method from different page will be invoked?
Yes you can, on master page you can have a Download Button and on it click check the URL, which will help you to identify the request has come from which page. Then you can write code on the basis of current page being displayed.
You can use the SHTML instead of HTML and include it every where that you need it.
I don't know what exactly You want to achieve, but maybe it would be better to have one aspx with the button and load the correct ascx file to this page according to some criteria? Each ascx can derive from some interface with some method, f.e. Click(), and each time the button on aspx is clicked, the Click() method from currently loaded ascx can be called.
I need to have a button on the master page.
Once that button is clicked I generate a string that represents URL.
test.apx is a content page I use and the string will look like something like this:
Example:
www.blah.com/test.aspx?user=blax&develop=extreme_all
Now all I need is to reload the page while content is redirected to the URL I generated.
I hope this makes more sense.
Thanks guys I am new to asp.net and really appreciate any help
Why dont you use Update Panel?
Have the page postback with the updated query string to change what is in your content area
Assuming your masterpage is set up correctly
within the <asp:content> tag of your aspx page that is using the masterpage you created add code to get the query string
Request.QueryString["key"]
example url: http://www.whatever.com?foo=bar&bar=foo
string tmp = Request.QueryString["foo"]
tmp will become "bar"
Now just check the "postback" option of the asp:control you're using to reload the content page or do whatever you to make the page refresh.
If I understand your question correctly, you want to reuse the same code to parse out your user and develop variables from different content pages that use the same master page.
It sounds like you need a strongly typed master page.
First, put your shared code in your master page. Then, expose the parsed data as properties of the master page. Next, simply add the following directive in your content pages:
<%# MasterType VirtualPath="~/mymasterpage.master" %>
Finally, in your content pages, you can reference your properties as such (assuming you created a property called MyUser):
string user = this.Master.MyUser;
You can also use inheritance if you want a different approach. Simply create class that inherits from Page. Then put your shared code in that class. Finally, make your content pages inherit from your new class, instead of Page.