|
Go the URL you like to go, do the process and then redirect to the original page... Done...
|
|
|
|
|
Thats great venkatesh, I really appreciate your answers. You have given ans to me even for many times. Thanks a lot, I wanted to give you this appreciation. Most of the times your ans will be true. Thanks for your dedication. Hats off.
S/W Engineer
Akebono Soft Technologies
aleem_abdul@akebonosoft.com.
|
|
|
|
|
|
Thanks for your reply. But i don't want to redirect to any other page. My requirement is as below
a) User will get email to his personal email id with one url which contains some querystring parm.
b) If user click on above url, then i want to do some operation e.g. best example is like we get emails from different registered site to inactivate my account.
Please suggest....
Amit
|
|
|
|
|
Do you want to close the window or hide the page? Hiding the page is not possible...
But we can close the window.
Use window.close() in the Page's OnLoad Event. Don't think closing the window will stop your process, because Server Script executes first and then only Client Script executes...
|
|
|
|
|
Sir,
Can I have a .Net made control(like UI) to display and edit the word and excel files. Its functionalities must be similar to DSO Framer control, but it should be prepared by using .Net framework or a .Net control. Please tell me if you have any Idea. Please.
S/W Engineer
Akebono Soft Technologies
aleem_abdul@akebonosoft.com.
|
|
|
|
|
Hey guys, I'm doing something similar to the example below (c# version):
http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/apps/cookies1/cookies1.src&file=CS\Cookies1.aspx&font=3[^]
Basically this sample has two different pages (cookies.aspx and customize.aspx). I'm implementing it in one page (i.e. when user click the right choices from the drop down lists, and click subit button, it should apply those properties and change the color, font size etc. Well when I first run the page (ctrl+F5). And the very first time that I select the properties from the lists, they get applied properly. Then if I go back to the drop down and change, lets say the color and text and hit submit again... it doesnt get applied and it needs the button clicked twice (i.e except for the intial request when it works on one click, you need the button to be clicked twice).
So it sounds like the initial GET request is working but when you submit (that is post back) that’s when its not behaving as expected.
Can someone please help...PLEASE NOTE in the original sample that you can run from here( http://samples.gotdotnet.com/quickstart/aspplus/samples/apps/cookies1/VB/cookies1.aspx[^]) above that there are two pages and that could be causing this behaviour since I only have one page but I just can't see where or how ????
Thanks for all your help
Tina
|
|
|
|
|
Sounds like you're setting some properties in your page load handler. This is fired before your event, so the event is changing a property, but the property has already been used until you click again. Two things to do here
1 - use the page prerender event for stuff that occurs after an event
2 - always set break points and debug your code to see what's happening when you have a problem.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Christian, I am new to software development and still learning the debugging techniques and stuff, but I did set up break points at page load and the handler for my click event, but can’t quite figure out why is it happening. The weird thing is that after going through the button click event’s code, control doesn’t return back to the browser window like it normally should and colors and stuff should change. Anyways I see your first point, could you please help me a little bit more as to what exactly I should be doing in the pre-render event. I haven’t used that one yet. And how?? I would appreciate any help I could get!
Thanks
Tina
|
|
|
|
|
Sure
Basically in .NET 2.0, the methods hook themselves up, any prior version, you need to hook it up. Your load event is being hooked up in code in a region, just add a hook to prerender. In 2.0, just put a
protected void Page_PreRender(object sender, EventArgs ea)
method in your code. The critical thing is, this is called AFTER the events, and is the place to put stuff that changes how the site looks, such as setting colors, or filling lists with data. I've not seen your code, so I am guessing, but I do know that your page load will be called before your events, so any changes to the site that happen in the event, unless they are done directly to controls, may not do what you hope. That is, if your event sets a private variable that stores the color, and your page load uses that variable to color some controls, the variable gets changed AFTER it is used. Using that variable in the prerender, uses it AFTER the event.
Again, I am guessing. I could give better help if I saw your code.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi Christian, yup when you told me in your response prior to this one, that I should try the PreRender method, I did that. And I did go into the designer generated code and explicitly wired the event handler for the pre render event (this.PreRender+=new System.EventHandler(this.Page_PreRender)).
Then I copied the same code that I have in my load event handler into Page_PreRender event handler. i.e.
<br />
public void Page_PreRender(object sender, System.EventArgs e)<br />
{<br />
if (!IsPostBack)<br />
{<br />
HttpCookie cookie = Response.Cookies["preferences1"];<br />
ViewState["Referer"] = Request.Headers["Referer"];<br />
<br />
if ( cookie != null )<br />
{<br />
BackColor.SelectedItem.Value = (string)cookie.Values["BackColor"];<br />
ForeColor.SelectedItem.Value = (string)cookie.Values["ForeColor"];<br />
LinkColor.SelectedItem.Value = (string)cookie.Values["LinkColor"];<br />
FontSize.SelectedItem.Value = (string)cookie.Values["FontSize"];<br />
FontName.SelectedItem.Value = (string)cookie.Values["FontName"];<br />
navControl.SelectedItem.Value = (string) cookie.Values["navControl"];<br />
}<br />
}<br />
userControl.Visible=false;<br />
<br />
}<br />
<br />
public void btnSubmit_Click(object sender, System.EventArgs e)<br />
{<br />
HttpCookie cookie = new HttpCookie("preferences1");<br />
cookie.Values.Add("ForeColor",ForeColor.SelectedItem.Value);<br />
cookie.Values.Add("BackColor",BackColor.SelectedItem.Value);<br />
cookie.Values.Add("LinkColor",LinkColor.SelectedItem.Value);<br />
cookie.Values.Add("FontSize",FontSize.SelectedItem.Value);<br />
cookie.Values.Add("FontName",FontName.SelectedItem.Value);<br />
cookie.Values.Add("navControl", navControl.SelectedItem.Value);<br />
Response.AppendCookie(cookie);<br />
<br />
if(GetStyle("navControl") == "Top")<br />
theControl.Visible = true;<br />
if(GetStyle("navControl") == "Bottom")<br />
This code above is pretty much from the Got dot net sitehttp://samples.gotdotnet.com/quickstart/aspplus/doc/stateoverview.aspx[^].
If you could please take a look at the link above for me...then you would see what I'm going through? Just scroll down to the CLIENT SIDE COOKIES on the link above and click view source. You will see they are doing this whole thing with two different pages (cookies.aspx adn customize.aspx) whereas I'm just using one, If you run the sample from there, you will see what I'm talking about. Also the only difference is that I converted those html select (drop down lists controld they have) into web server controls. I wonder if that has something to do with the problem I'm having since it might be going out to the server for no reason?
Thanks once again for all your help.;)
~TINA
|
|
|
|
|
Tina P wrote: if (!IsPostBack)
This part means your code will never work. By checking this, your code only works the first time the page is opened, and never on a postback. Remove it, or otherwise, have your event handler set the local properties, as well as the cookie. That would make the most sense to me, in a lot of ways.
if (!IsPostback) is used to read settings only the first time a page is opened, and is generally used where an initial state is read, then later changed by the page. For example, on first load, a data driven control would read it's data from the database, but it's both expensive and causes state to be lost, to read it every time. Rather than keep reading hte cookie, it makes more sense to store changes in both the cookie, and the local settings, in the event code. That would also allow you to do this code in the page load ( the pre render problem would have been the issue if the !IsPostback code had not been present )
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Christian, well trust me I've tried alot of things and removing the Page.IsPostBack property was one of them. It still does the same thing (i.e button needs to be cliecked twice).
About your statement below, could you please show me (by perhaps some sample code how to do that)
<quote>
"Rather than keep reading hte cookie, it makes more sense to store changes in both the cookie, and the local settings, in the event code."
Also did you look at the code from the link I sent you prior to this message...that's very similar to what I have. And any thought on making those web server controls into html controls as I mentioned in the pervious post??
Thanks
~Tina
|
|
|
|
|
Oh - wait - what are BackColor, etc ? Looks to me like they are drop lists. I see no code to set any actual properties on your page here then, just code to move values between the drop lists and a cookie.
Tina P wrote: nd any thought on making those web server controls into html controls as I mentioned in the pervious post??
Well, a server control ends up rendering itself as a HTML control, if you want to use properties that only the server control supports, then it won't happen, if you just want to render controls, just change their type.
What I was suggesting was that you move the code that sets properties of your page into the event, but I now realise, there's no code setting page properties at all. Not that I can see, anyhow.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Yes they are the IDs for the drop downs.
"Oh - wait - what are BackColor, etc ? Looks to me like they are drop lists. I see no code to set any actual properties on your page here then, just code to move values between the drop lists and a cookie."
You are right, the code to set the colors and otthers is actually done in the aspx page:
<br />
body{<br />
font: <%=GetStyle("FontSize")%> <%=GetStyle("FontName")%>;<br />
background-color: <%=GetStyle("BackColor")%>;<br />
GetStyle is the function that returns the style based on user selection:
public string GetStyle(String key)
{
HttpCookie cookie = Request.Cookies["preferences1"];
if (cookie != null)
{
switch (key)
{
case "ForeColor" :
return cookie.Values["ForeColor"];
break;
case "BackColor" :
return cookie.Values["BackColor"];
break;
case "LinkColor" :
return cookie.Values["LinkColor"];
break;
case "FontSize" :
return cookie.Values["FontSize"];
break;
case "FontName" :
return cookie.Values["FontName"];
break;
}
}
return "";
}
Is there are a way to eliminate this issue? I'm soooo frustrated
Thanks
~TINA
|
|
|
|
|
OK, it's easy then. The ASPX is executed *first*, you can't make this happen after your event is fired. So, you need to change how the code works, for this to work. You'll need to probably use CSS, and write the CSS classes out inside your prerender. Your problem all along has been what I said, even if it took me a while to nut out hte detaisl. The values in your cookie get written out *before* your event changes them.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi Christian, okay! So you are saying that aspx (the server side code in their) is executed first before the button is clicked.
Alright so if you notice in the code sample at gotdotnet site i sent you, they are using an inline CSS (unless I'm totally wrong). So if I understand you correctly, you are saying that some how don't call that GetStyle() method from the aspx page like this
<table style = "color:<%=GetStyle("ForeColor") %> (BTW this is CSS inline version right??).
Could you give me an example of how to use classes like you mentioned?
I'm thinking there's got to be a way to get this to work even without the external style sheet. In other words like you said do it from within pre-render but with this same style sheet.
Please help
Thanks
~TINA
|
|
|
|
|
<table style='myCSS'>
would mean the table gets it's CSS from the myCSS class. Your code behind can now write the CSS class into the page, and thus define the style sheet there. The other option is to ditch the aspx code and set properties on the table itself ( that is, give it a name and access it's properties in the code behind ). A third ( somewhat nasty ) option is to have the event handler store the cookie, then redirect to itself, so that it starts the page lifecycle all over again.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Cool, thanks Christian. I think I'm thinking about using the second approach you mentioned. Use the ID of table and body to change the color, but I wonder if this will work for the font color, font size and font name properties as well???? Because I'm changing those as well???
Thanks
~TINA
|
|
|
|
|
Christian, like i was wondering earlier in my response...from code behind it does change the backgroundcolor
theBody.Attributes["bgcolor"]= Convert.ToString(GetStyle("BackColor"));
But it doesn't have any properties for the font size, font name etc.
In other words I can't do something like this:
<br />
theBody.Attributes["font-size"] = GetStyle("FontSize");
theBody.Attributes["font-style"] = GetStyle("FontName");
Am I doing something wrong here???
Thanks
~TINA
|
|
|
|
|
Dear all,
i am making web application using Asp.net,C#(VisualStudio2005).in a web page there is a dropdownlist control
on edit command, i am trying to populate it as
for (int i = 0; i < DropDownListprob.Items.Count; i++)
{
if (rdr["ProbCode"].Equals(DropDownListprob.Item[i].Text))
{
DropDownListprob.Items[i].Selected = true;
//MessageBox.Show(DropDownListprob.Items[i].Text);
}
}
but it is showing error as follow. i have only three record in dropdownlist. adn i am populating one of them.i am not able to understand the porblem as it is showing multiple item can not be selected.
Error showing
Cannot have multiple items selected in a DropDownList.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Cannot have multiple items selected in a DropDownList.
regards
imran khan
|
|
|
|
|
Hi,
There is No logical error with you code.
You may Check the 'DropDownListprob', whether it contains Unique Values ( No Repeated Items). AND also, whether the 'DropDownListprob' already have any selected Items.
Regards,
Jay
|
|
|
|
|
mohd imran abdul aziz wrote: for (int i = 0; i < DropDownListprob.Items.Count; i++)
{
if (rdr["ProbCode"].Equals(DropDownListprob.Item[i].Text))
{
DropDownListprob.Items[i].Selected = true;
//MessageBox.Show(DropDownListprob.Items[i].Text);
}
}
mohd imran abdul aziz wrote: Exception Details: System.Web.HttpException: Cannot have multiple items selected in a DropDownList.
Shows that the some items in the DropDownList are same... check the DropDownListprob.Items[i].Text.
|
|
|
|
|
Hi,
My query is as follows...
I have set of documents stored using Sharepoint(document management tool). I have to search for a particular keyword or phrase in the content of all the documents stored through sharepoint and get the list of documents result whose content containe the searched keyword.
I am new to sharepoint, could anyone of you help me with the code for the logic above....
Thanks in advance.....
Usha
|
|
|
|
|
Hi,
I am working on a .Net web based application and like to setup auto logout when the user closes the browser. This is what happening so far,
I am creating the Form authentication ticket manually and setting up the expiration for 5 minutes. So whenever the user leaves the application ideal for more than 5 minutes it will ask them to login for next request. But when they closes the Browser window without logged out manually and opening the browser immediately they are logged in already, but it is asking them to login when they open the browser after 5 minutes.
But I want to keep the timeout function as it is and like to logout the user immediately when they close the browser.
I tried it with adding code FormAuthentication.singout(); Session.Abandon(); to Application End and session end of global.aspx.cs, but nothing worked.
Is there any other way of doing it?
PS: Using .Net 1.1
Please help me.
Thanks and Regards,
Renu
|
|
|
|
|