Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi friends i have a small doubt..pls help me

 

i have a function which returns applicationID..i want to pass that ApplicationID to all of my web pages..

 

my function

-----------

<script language=vb runat="server">

public function getID()

dim Idval

Idval=Request.querystring("id")

getId=Idval

end function

</script>

 

 

in my webpage(applInformsec1.aspx) i am writing the code like this

 

<tr align=center width="200">

<td><A href="appstatus1.aspx?ID=" &<%=GetId%> runat="server"><b

>Applicantion Status of Appliant

<%=getId%></B></A></TD></TR>

<TR align=center width="200">

<td><A href="testHistory1.aspx?ID=" &<%=GetId%> runat="server"><b>Test

History of Applicant

<%=getId%></B></A></TD></TR>

 

 

I am getting the error server tag not scripted well..pls give me a idea how can i pass values with hyperlink..and give me a idea abt Hidden variables also..

 

Thank you

satya

Satya
Posted

You do not have to bother with hidden variables in asp.net cause the framework handles this for you!! I recommend you read and fully understand the concept of viewstate and how postback works in asp.net!

 

Short, I can say that all the values in your form page will automatically be saved in the viewstate upon postback (unless the control has enableviewstate = false)

 

You can access values in the viewstate by using "viewstate" object...

 

it is a whole new concept in asp.net... forget manual editing of hidden fields.

 

About your querystring, is it possible to make <%=var%> in asp.net? I suggest you check <%# databinder.eval(somevalue) %>

 

 

the <%# is a databinding expression and is used when you in the asp page want to bind a value to something... it might not work in this case since you ar enot really binding the value to a control, but do a search on the forums for querystrings in asp.net...

 

 

kind regards

Henrik

Posted

Hey MrNorth, Thanx for the input, however, I do understand the passing of the viewstate (as long as the page is submitted by either Server.Transfer() or by the form action (post)).

 

You can use the Cache.Insert and Cache.Get if your parameters can be set in the program in advance, however, consider the following scenario:

 

You're building a table (kinda like a datagrid) that contains a row for each row in the database, andyou would like to include a button or hyperlink to edit or delete each row in the lefthand column.

 

as you assemble each row of the table, you create a button like: <input type=button value="Edit" onClick="EditRecord(1001)">

or a hyperlink like ...

<a href="#" onClick="EditRecord(1001)">Edit</a>

 

You add a little javascript function:

 

function EditRecord(recd_id) {

window.open("MyPage.aspx?mode=edit&recd_id=" + recd_id);

}

 

The record ID (1001 in this case) is the unique key for the record to be edited, taken from the datatable while assembling the row.

 

You will have no way of knowing in advance which button the user will want to click, so cacheing values won't help.

 

By parsing the query string in MyPage.aspx, you can determine that the user wants to 'Edit' the record with recd_id "1001".

 

 

Another note: you can append to the window.open URL:

"&random=" + Math.Random()

 

This adds a random number to the query string (you can ignore) which forces the client's browser to reload the page instead of retrieving it from cache.:D

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...