Hyperlinked Numbers

arun_mrk

Well-known member
Joined
Apr 1, 2003
Messages
51
Location
beijing
I want to create a hyperlink number something like 1 2 3 at runtime(because I know the starting and ending number only the runtime). When 1 is clicked the web page should page postback(not new page) again and I should be able to retrieve the value of the hyperlinked number(in this case its
 
You need postback to capture the values of your page control? If not then you can use Querystring to pass the number.

for example, the link for 1 is "index.aspx?page=1", link for 2 is "index.aspx?page=2", you got it?

If need postback, then one of the choice is use hidden textbox to store your value before page postback.
 
thanx for the reply.
You r right that i cannot use request.querystring bcoz i want the web page to post back.
Could u post some code for ur second option(hidden textbox)?
 
For second option, actually there are many choices, like Cookies and Session also can do it, as long as there is a space for you to store the page number...

How are you going to postback using a hyperlink? that hyperlink call a javascript function? Did you use Cookies or Session before? which method you prefer?
 
HTML does not support posting back via a anchor (link). You can rig up a JavaScript function that will allow you to do it, however personally Id consider that a poor solution. Why cant you use the query string method, as bungpeng suggested? This is how most, if not all web applications perform paging.
 
i make clear y i cannot use query string for the paging.

My web page has multi row edit option.
Im picking ten rows at a time from database using stored procedure and displaying it in the datagrid.
The users might make changes to these rows and navigate to the second page(by clicking hyperlink 2 ) at the time i have to save the records(first page records).

In this case if i use querystring, a new page is loaded. So where(which event) can i write my save routine.

If i can post back rather than loading the page again(using querystring) i can trap the changes in the page_load and save.
After saving the changes i will load the next set of records.
 
Last edited by a moderator:
Do you know javascript? When user press the Next button, then you call javascript function, this function will perform 2 tasks, one is assign the page number in hidden textbox, another one is buttom the form.

Is something like this
function nextPress() {
document.form1.txthidden.value = intPageNum;
document.form1.submit();
}

It is also depend on how you handle your multi-row edit... I will rather suggest you allow user edit one row at one time.
 
im newbie in javascript.

but certainly i understood the code u had provided in earlier post.
but now, i want is how to generate intPageNum.
Which control(or tag) should i use and how used i pass intPageNum to the javascript function.
 
In ASP or ASP.NET, you can easy get the page number through Requst.Form("txthidden") right? then you can also pass this value to javascript. It is also depend on how you control your javascript code, for example, if my javascript code sit together with HTML code like traditional ASP, then I can:

function nextPress() {
document.form1.txthidden.value = <%=intPageNum%>;
document.form1.submit();
}

It is not a problem to pass value from server site language to client site (like ASP.NET to javascript), but not client to server.

What do you mean "Which control(or tag) should i use"? What is this control for?
 
now i have to pass the page number from the server to the client script (which u had provided).
how to do it?

Ok!before that i have to create a page number like
1 2 3
how to do it(which control like linkbutton or tags like anchor etc should i use and how to post back this values to the client script function-nextpress())
 
Sound like you quite new to ASP.NET...

What had you did now? At least let me know what make you stuck, then I can help you to proceed.

Are you using DataGrid? there is Paging feature provided by DataGrid. I was wrote a sample code for you about passing the page number from server to client in previous thread, you can understand? or what?

I think in forum you cannot expect people write a whole page source for you.
 
i guess, i can stop here.
I had lost the confidence that this thread will provide me the desired result.
anyhow thanx.
 
Back
Top