|
Tell me what you did so far.
Just do like this :
write
Response.Cookies["txtCookie"].Value = myid;
Response.Cookies["txtCookie"].Expires = DateTime.Now.AddDays(1);
inside your masterpage, and it will be accessible to any page that inherits masterpage (also normal pages)
I have done this a lot of times, and it worked perfectly...
To request the cookie use
Request.Cookies["txtCookie"]
|
|
|
|
|
but my id keeps on changing depending on the no. of tabs opened(Firefox). And Each tab has to maintain different ids(customerId for instance).
Example
I have a gridview having multiple customers.
if i open multiple customer details on multiple tabs then there should be different customerid assigned to different pages.
In case if i use cookie then it will store a single customerid and when the page makes a request then this id will be assigned to all the pages. I dont want to do like this.
I dont think, this is a solution(i.e. Cookie)
Everything Is Possible!
|
|
|
|
|
Ok..
As per your requirement is concerned, I think database is the best solution. Even If I was doing this application, I will always use Database.
Actually session/viewstate cannot be used to do what you want.. .thats for sure.
Other than that, you can use Application object which will reflect to all the session, ... But believe me, from my personal experience I would suggest not to use it, because Server memory is very important, and if your application is using excessive server memory, it may be of high probability of getting the site down any time.
So, You have only 2 option,
1. Cookie (Which you dont want) : you can store as many customer ids as you want. As this is stored in client side, performance will not be hampered for the site.
2. Database / XML file in server : I think this is the best way. Its secured and everyone in your situation would have chosen this.
Now it depends on you which one you choose.
Let me know about it.
|
|
|
|
|
I really appreciate your help but i dont think this is a better solution.
I would rather create a public property in the masterpage and cast the masterpage in all my content pages(there are around 40-50 pages).
although it is a tedious work.
I will store the id in the content page's viewstate.
Everything Is Possible!
|
|
|
|
|
But where it will get the Id ... In server side ??
Id should be stored at least somewhere to communicate. Do you think only a property can make things ok. Every time a web request is made a new object of the whole page will be created. If you open a new tab, there will be no communication between the original page(Even session is different)
So it will always hold the default value of the property. Viewstate will be refreshed for every page, so it cant get the values that you created in another page.
Anyways...
thanks for your appreciation. But I am still not sure what you are upto...
Best wishes.
|
|
|
|
|
I will assign the viewstate to the property.
Regards,
Suresh Dayma
Everything Is Possible!
|
|
|
|
|
Create the public property in Master page.
Cast the master page in content page
MasterPage mymasterpage = Page.Master as MyMasterPage;
Use the property in content page to access the customer name.
Response.Write(mymasterpage.CustomerName);
Try it, if it is working
Regards
Aftab Sindhi
.NET Application Developer
U.A.E
|
|
|
|
|
I dont want to make changes in all the content pages because there are around 40-50 pages.It's tedious to incorporate this changes to all the files.
Is there a way by which i have to modify only the master page?
Everything Is Possible!
|
|
|
|
|
how can i rotate an image in image control by arbitrary angles ??
M.Alizadeh
|
|
|
|
|
|
thanks for your help
but it coudnt help me
i want to rotate an image in image control not in a new page...(first link)
seccend is for win app:
pictureBox.Image = Utilities.RotateImage(img,(float) angle.Value );
image has not image properties
M.Alizadeh
|
|
|
|
|
AFAIK, html image control couldnt be rotated. You can define the size of the img but cant rotate.
To do this, you need to rotate the image in the server and produce another image and show it in browser. Use graphics object to draw a new image rotating it in an angle and show it in browser.
This article could be a good help for you :
Image Rotation in .NET[^]
After you rotate the image, show it using img tag.
On the other hand:
If you want to rotate in browser itself, you might use Flash / silverlight which are capable of doing this.
Hope you got this.
Cheers
|
|
|
|
|
|
I think this javascript uses moveto function to actually rotate an image.
Use this Javascript
http://www.walterzorn.com/scripts/wz_rotateimg.js
I think you can do this without Flash and Silverlight.
|
|
|
|
|
Hi, i want to read data from the source file of 3rd party website. The page is not in my control. Here i need to do two things.
a. I just read the html content of that page in to string first
b. and later i want to retrive some specific data from that string.
the first option is ok. The second option i am not getting how to retive the data.
<tr>
<th>First Name</th>
<td width="100%"><input name="p_first_name" type="text" id="f-first-name" value="JEAN" /></td>
</tr>
<tr class="tr-back">
<th class="tr-back">Last Name</th>
<td><input name="p_last_name" type="text" id="f-last-name" value="AAREN" /></td>
</tr>
<tr>
<th>Occupation</th>
<td width="100%"><input name="o_occ" type="text" id="f-occ" value="UNKNOWN" /></td>
</tr>
In the above code i want to retrive the values first name, middle name and lastname. i.e JEAN, AAREN, UNKNOWN
Can any one help me how to retrive this code once reading all this html in to string..? or any other way
|
|
|
|
|
If you are sure that the resultant string is in valid XML format, just load it to XmlDocument and use XPath to get the required values. Other option is to use regular expression and look for the text.
Best wishes,
Navaneeth
|
|
|
|
|
how to load that string in to xmldocument?
G. Satish
|
|
|
|
|
|
If you place a wrapper to all the tr's it will load easily in XMLDocument / XDocument.
Just take the table tag which wrap around all the entries.
Use XElement.Load(your html string) to get the xml loaded.
Now search the elements using Linq to XML.
Cheers...
|
|
|
|
|
Dear all
I want to make a web site as a book on asp.net but the pages are jpg images not text and i can make next >> and previous <<
which controle i can use to navigate through the images in this book
thank u for advice
Kareem Elhosseny
|
|
|
|
|
Just use client side button.
When onclick to button, make an ajax call to the server(might be a dedicated handler) and change the src or img tag.
|
|
|
|
|
thanks my brother
Kareem Elhosseny
|
|
|
|
|
Here is a code project in asp.net.
i have to insert dynamically create rows in a table name : [Pin_Generate]
The number of rows are inserted by the user and then submit and it create that number of rows in that table.
But it cannot be done when its going 2nd time in a loop...
<br />
for (i = 1; i <= Convert.ToInt32(EnterByUserTextBox.Text); i++)<br />
{<br />
getNum();<br />
<br />
scomm1.Parameters.AddWithValue("@pid_no", lblprint_id.Text);<br />
scomm1.Parameters.AddWithValue("@pserial_no", lblserial_no.Text);<br />
scomm1.Parameters.AddWithValue("@ppassword", lblpassword.Text);<br />
<br />
sconn1.Open();<br />
int x = 0;<br />
x=scomm1.ExecuteNonQuery();
sconn1.Close();<br />
<br />
<br />
if (x > 0)<br />
{<br />
<br />
lblmsg.Text = "Successfully Created";<br />
update();<br />
<br />
}<br />
else<br />
{<br />
lblmsg.Text = "Please Try Again";<br />
}<br />
<br />
<br />
}<br />
Plz help me out.... its very urgent..
|
|
|
|
|
Welcome to CodeProject! Please read the forum guidelines[^] to learn how to ask better questions. People here do voluntary help and specifying urgent in the message won't help you to get answers. It is considered as rude.
To answer your question: what error are you getting? What getNum() function is doing?
There are few problems in your code. You are adding parameters in each iteration which is not correct. If you want to insert the same value N times, you don't have to open and close the database connection each time. Open it once, call ExecuteNonQuery() N times and close the connection. Here is the code after few refactorings.
int n;
if(!int.TryParse(EnterByUserTextBox.Text, out n))
{
}
using(SqlConnection sconn1 = new SqlConnection(connectionstring))
using(SqlCommand scomm1 = sconn1.CreateCommand())
{
scomm1.Parameters.AddWithValue("@pid_no", lblprint_id.Text);
scomm1.Parameters.AddWithValue("@pserial_no", lblserial_no.Text);
scomm1.Parameters.AddWithValue("@ppassword", lblpassword.Text);
try
{
sconn1.Open();
for (i = 1; i <= n; i++)
{
scomm1.ExecuteNonQuery();
}
sconn1.Close();
lblmsg.Text = "Successfully Created";
update();
}
catch(Exception ex)
{
lblmsg.Text = "Please Try Again" + ex.ToString();
}
}
Best wishes,
Navaneeth
|
|
|
|
|
Good Answer Navaneeth...
Additionally I have also marked this as answer...
Cheers.
modified on Saturday, November 14, 2009 1:51 PM
|
|
|
|