Showing posts with label back. Show all posts
Showing posts with label back. Show all posts

Wednesday, March 28, 2012

the code in visual basic.net

how do i make the code stay in place in visual basic.net?
when i go to the design view and then back to the code view then my code has all been put to the left side and the structure that i made with tabs is gone..

can i choose somewhere not to make that happen?

so i don't have to tab all over again?That's real odd. Mine does the opposite. It auto tabs and makes everything look purty. :)

Monday, March 26, 2012

The damn Enter button and ASP.NET

If you have a Datagrid with the functionality to edit and update rows and
then also a Save, Add new and Back buttons at the bottom of the page. The
Enter button is all messed up... add to this a bunch of TextBox fileds with
Multiline support in the Edit mode...
So if I enter the Edit mode of a row and put focus in the multiline textbox
and press enter I of course want to create a line feed in the text box.. but
no.. it triggers any button the page feel like at that time... when you tab
around in the Input fields you see the blu little line jump around on
buttons (that indicated the Defautl Enter button)... Sometimes it's the save
button that triggers and sometimes in the back button or sometimes even the
deletecommand of the other rows that are not in the EditMode.
So, yeah sure I could, which I have on other pages, disabled the Enter and
Return buttons thru Javascript onkeypress but on this page I really need to
have the line feed thingy working in the Multiline boxes.. please help.
best regards
/Lars NetzelHi Lars
I've had the problem with ASP pages submitting the first button on the page
or not the button i intented it to submit.
The way i got around this, was by creating a <input type=button runat=server
id=tb />, setting the OnClick to point to my required method through the
code behind, then attaching a JavaScript on enter to all the textboxes i
want to submit this with. (the opposite to you disabling the enter button)
An annoying work around, but a work around.
I have never had the problem when hitting enter on a multiline textbox, it
submits the form.
However, attaching a Javascript onclick like i said above would do this.
So, are you sure there no javascript actions on you textbox that could cause
it to submit on enter rather than create a new line feed.
Double check this through IE by viewing source and checking there is no
OnClick event.
HTH (I know it may be no solution, by no one else has answered your plea for
help yet :))
"Lars Netzel" <uihsdf@dotnet.itags.org.adf.se> wrote in message
news:OGu697XoFHA.3316@dotnet.itags.org.TK2MSFTNGP14.phx.gbl...
> If you have a Datagrid with the functionality to edit and update rows and
> then also a Save, Add new and Back buttons at the bottom of the page. The
> Enter button is all messed up... add to this a bunch of TextBox fileds
> with Multiline support in the Edit mode...
> So if I enter the Edit mode of a row and put focus in the multiline
> textbox and press enter I of course want to create a line feed in the text
> box.. but no.. it triggers any button the page feel like at that time...
> when you tab around in the Input fields you see the blu little line jump
> around on buttons (that indicated the Defautl Enter button)... Sometimes
> it's the save button that triggers and sometimes in the back button or
> sometimes even the deletecommand of the other rows that are not in the
> EditMode.
> So, yeah sure I could, which I have on other pages, disabled the Enter and
> Return buttons thru Javascript onkeypress but on this page I really need
> to have the line feed thingy working in the Multiline boxes.. please help.
> best regards
> /Lars Netzel
>
Thank you! I had some thoughts about the way you suggested but it seemed
like such an ugly workaround that I didn't really think that anyone would do
it but after looking around so more it seems like this is a quite common way
of fixing things, using the onfocus and onblur events to alter behaviors on
page.
So I did this:
I catch onkeypress on the body element and have a condition for the Enter
button to return true or false... then on the onfocus and onblur events of
the textboxes, I change a variable weather to use the condition for the
enter check or not. Work pretty darn good:)
Thanks for the thoughts.
And by the way.. the textboxes where not set to MultiLine... hmmm.. I wonder
why there was no LineFeed...
Take care
/Lars
"Grant Merwitz" <grant@dotnet.itags.org.workshare.com> wrote in message
news:eEV7z1ZoFHA.3608@dotnet.itags.org.TK2MSFTNGP15.phx.gbl...
> Hi Lars
> I've had the problem with ASP pages submitting the first button on the
> page or not the button i intented it to submit.
> The way i got around this, was by creating a <input type=button
> runat=server id=tb />, setting the OnClick to point to my required method
> through the code behind, then attaching a JavaScript on enter to all the
> textboxes i want to submit this with. (the opposite to you disabling the
> enter button)
> An annoying work around, but a work around.
> I have never had the problem when hitting enter on a multiline textbox, it
> submits the form.
> However, attaching a Javascript onclick like i said above would do this.
> So, are you sure there no javascript actions on you textbox that could
> cause it to submit on enter rather than create a new line feed.
> Double check this through IE by viewing source and checking there is no
> OnClick event.
> HTH (I know it may be no solution, by no one else has answered your plea
> for help yet :))
>
> "Lars Netzel" <uihsdf@dotnet.itags.org.adf.se> wrote in message
> news:OGu697XoFHA.3316@dotnet.itags.org.TK2MSFTNGP14.phx.gbl...
>
HAHA, thats is quite funny
glad you came right
"Lars Netzel" <uihsdf@dotnet.itags.org.adf.se> wrote in message
news:u7Dn3sioFHA.468@dotnet.itags.org.TK2MSFTNGP15.phx.gbl...
> Thank you! I had some thoughts about the way you suggested but it seemed
> like such an ugly workaround that I didn't really think that anyone would
> do it but after looking around so more it seems like this is a quite
> common way of fixing things, using the onfocus and onblur events to alter
> behaviors on page.
> So I did this:
> I catch onkeypress on the body element and have a condition for the Enter
> button to return true or false... then on the onfocus and onblur events of
> the textboxes, I change a variable weather to use the condition for the
> enter check or not. Work pretty darn good:)
> Thanks for the thoughts.
> And by the way.. the textboxes where not set to MultiLine... hmmm.. I
> wonder why there was no LineFeed...
> Take care
> /Lars
>
> "Grant Merwitz" <grant@dotnet.itags.org.workshare.com> wrote in message
> news:eEV7z1ZoFHA.3608@dotnet.itags.org.TK2MSFTNGP15.phx.gbl...
>

Saturday, March 24, 2012

The dreaded back button

Within an application, is there any way to "tamper" with the history of URLs retained by the browser, so that I can control the URL associated with the back button?

I guess this would entail deleting the last page from the linked list that the browser holds for pages that I do not wish to revisit.

Is this possible?Because of security reasons, you can't get the history from the client.

The Error

I was developing an ASP.NET web application..and suddenly..i got hungry...i saved everything and closed Visual Studio.Net (2003) ..ate...back to VS.NET..start my application...then..i got this error

Visual Studio cannot create or open the application because the web server on this computer is not running. Start the web server before processing.

Now,this is my whole story..i did nothin to VS ..what should i do

(i found that the web server is running..i stopped it..then restarted it..but in vain...un then re install the iis....restart windows (XP pro) ..and i got the same error)

try running the regiis, that sometimes fixes the problem and you should do it after re-installing iis.

C:\WINNT\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -i


MxMxM wrote:

I was developing an ASP.NET web application..and suddenly..i got hungry...i saved everything and closed Visual Studio.Net (2003) ..ate...back to VS.NET..start my application...then..i got this error

Visual Studio cannot create or open the application because the web server on this computer is not running. Start the web server before processing.

Now,this is my whole story..i did nothin to VS ..what should i do

(i found that the web server is running..i stopped it..then restarted it..but in vain...un then re install the iis....restart windows (XP pro) ..and i got the same error)

You may just re-start your IIS server.


i tried everything...aspnet_regiis.exe /i ...stop and restart...remove the IIS and add it again..then aspnet_regiis.exe /i ...

Thursday, March 22, 2012

the explorer window scroll is not kept although smartnavigation=true

Here is my page directive, but the scroll is not kept in its place afte a post back any idea, pls:
<%@dotnet.itags.org. Page language="c#" Codebehind="sap.aspx.cs" AutoEventWireup="false" Inherits="WebForm1" smartNavigation="true"%>
Thankstry setting MaintainScrollPositionOnPostBack = True
sorry i forgot to mention i am using 2003 net 1.1
Thanks

The Focus() method dont work

As title, druing a button-click post back, I set a control, say Button1, to get the focus by Button1.Focus();

However, after the page is rendered, the Button1 still do not gets the focus as if browser window itself gets the focus instead.

Could any body give me some tips the find out the problem?

Note: The page is copied from an existing one and do some modification.

Thanks a lot

Ricky

Regards

it could be that the page is focusing somewhere else due to javascript, or just the browser...

but if you add the following code to your page, you should be able to re-focus where you want it... (add this code at the bottom of your page with the Page.ClientScript.RegisterStartupScript method):

setTimeout(function() { document.getElementById("myTextBox's Client Side ID here...").focus(); }, 250); <-- this will do it after 250 milliseconds (adjust to your needs).

Peace,


Nullable:

it could be that the page is focusing somewhere else due to javascript, or just the browser...

but if you add the following code to your page, you should be able to re-focus where you want it... (add this code at the bottom of your page with the Page.ClientScript.RegisterStartupScript method):

setTimeout(function() { document.getElementById("myTextBox's Client Side ID here...").focus(); }, 250); <-- this will do it after 250 milliseconds (adjust to your needs).

Peace,

Thanks. I have found the bug caused by the invalid HTML markups.

Ricky

Tuesday, March 13, 2012

The infamous post back issue regarding the DropDown list control

Hi everyone,

I'm having a problem with using the DropDown list control in ASP.NET 2.0 and the selected item name not being retained in the control. I have this control on a MasterPage and when you select Blue I do a Response.Redirect to a content page. The problem is I'd like the DropDown list control to retain the name Blue, but it doesn't work it always displays the blank from "" after you make your selection. I have ViewState enabled as well as AutoPostBack on the DropDown list control set to true. If I set AutoPostBack to false, then the selected name is retained, but the Response.Redirect doesn't fire. Please note below:

//MySiteMasterPageprotected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ColorsDropDownList.Items.Add("");
ColorsDropDownList.Items.Add("Red");
ColorsDropDownList.Items.Add("Green");
ColorsDropDownList.Items.Add("Blue");
ColorsDropDownList.Items.Add("Yellow");
}
}

protected void ColorsDropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
switch (ColorsDropDownList.SelectedValue)
{
case"Red":
Response.Redirect("~/Red.aspx",false);
break;
case"Green":
Response.Redirect("~/Green.aspx",false);
break;
case"Blue":
Response.Redirect("~/Blue.aspx",false);
break;
case"Yellow":
Response.Redirect("~/Yellow.aspx",false);
break;
}
}

I have searched thorough the forums for similiar issues, but everything I've tried either hasn't worked or was not close enough to my situation.
Thank you, 

What you need to understand about Viewstate isthat it is only applicable within a single page during postbacks; thatis, once you switch pages, all the page data from the prior page isgone.

However, if you must redirect to adifferent page for each color -- and I'm not sure you have to do that,since you could easily make one dynamic page -- you can hard-code theselected value of the DDL for each page. That is, if you're onthe Blue page, youknow the user picked Blue, so you can just set it when the page loads.

Cheers,


I may not have explained this properly. First I tried to pick colors as a simple example; however, the actual application is for a reporting application. There is a MasterPage that contains the TreeView control showing the reports the user is able to access based on their user role. The DropDownList control represents various departments. When the user selects one of the reports they have access to it is displayed in the TreeView it displays the department page with the selected report. Following what you suggested by hard coding I'm not following how to set the DropDown control manually to the department page name that was selected from the DropDownList control.

Report Portal

----------------------------------------------------------

Select: contains the list of depts|

General Rtps | Actual report content is displayed in this area.

Financial Rtps |

Sales Rpts |

Top 5% Sales |

Top 20% Sales |

Inventory Rtps |


Hi

I tried to work the same thing it seems to have worked fine for me, I am giving the full code that I used, may be that will help

MasterPage

-----------------------

<%@. Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID=ColorsDropDownList AutoPostBack=true runat=server OnSelectedIndexChanged="ColorsDropDownList_SelectedIndexChanged1"></asp:DropDownList>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>
------------------------

Master page code behind

---------------

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ColorsDropDownList.Items.Add("");
ColorsDropDownList.Items.Add("Red");
ColorsDropDownList.Items.Add("Green");
ColorsDropDownList.Items.Add("Blue");
ColorsDropDownList.Items.Add("Yellow");
}
}

protected void ColorsDropDownList_SelectedIndexChanged1(object sender, EventArgs e)
{
switch (ColorsDropDownList.SelectedValue)
{
case "Red":
Response.Write("~/Red.aspx");
break;
case "Green":
Response.Write("~/Green.aspx");
break;
case "Blue":
Response.Write("~/Blue.aspx");
break;
case "Yellow":
Response.Write("~/Yellow.aspx");
break;
default:
Response.Write("~/default.aspx");
break;
}
}
}
----------------------

Default page

----------

<%@. Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
</asp:Content

------------

Hope this helps

thanks

vikram

Vikram's Blog


Ok, yes trying your example does work; however, I am not doing a Response.Write("~/Red.aspx");. I am doing a Response.Redirect("~/Red.aspx", false) to send the user to a page called Red.aspx. Actually this is just an example and not the actual name of the page the user is be redirected to.

Is it possible to get the same effect as using Response.Write, but instead use Response.Redirect??

Thanks,

Lance


When you do a Response.Redirect, all the ViewState information is lost. You need to use a different type of session state to keep track of the value

You could store the value in a session variable and then after the response.redirect read from it

Session["ddlIndex"] = ddlDropDownList.SelectedIndex;

Response.Redirect("otherpage.aspx");

On the other page you would do this

ddlDropDownList.SelectedIndex = (int)["ddlIndex"]


Thanks for the reply James. I see what you are saying, but when I try to compile this I receive a few errors on the line on the other page.

ddlDropDownList.SelectedIndex = (int)["ddlIndex"];

Invalid expression term '['

; exprected

; expected

Invalid expression term ']'

How do I fix this? Also that above line will still maintain the name of the item that was selected from the drop down list control even though the control resides on the Master Page and this is just a content page??

Thanks


It should be ddlDropDownList.SelectedIndex = (int)Session["ddlIndex"];

I didn't check the code so it may have minor syntax errors like forgetting the ; terminator.


Ok, i should have caught that Session was missing also. That takes care of that problem, but I still have an issue with the Drop Down List Control. The name doesn't exist in the current context, because it is located on a different page.