Showing posts with label value. Show all posts
Showing posts with label value. Show all posts

Thursday, March 29, 2012

Please explain strange viewstate behavior...

I am dynamically adding an HtmlInputHidden element with different values.
The problem is the first time I add it with a given value and submit it then
change the value within the Page_Load event it still has the original value.
I am guessing this has something to do with viewstate. I have turned off
viewstate at the page level, but the issue still occurs. Any suggestions?
The code is basic:
HtmlInputHidden phihAction = new HtmlInputHidden();
phihAction.ID = "hdnAction";
phihAction.Value = ((short)pactAction).ToString();
mfrmUser.Controls.Add( phihAction );
pactAction is an enumeration that changes based on action (i.e. 1=Add, 2=Edi
t)
Any help in understanding why it does what it does and how to work around it
would be greatly appreciated.
RobertRobert,
You need to check IsPostBack property befory assigning the value:
HtmlInputHidden phihAction = new HtmlInputHidden();
phihAction.ID = "hdnAction";
if (IsPostBack)
phihAction.Value = ((short)pactAction).ToString();
mfrmUser.Controls.Add( phihAction );
Eliyahu
"rgrandidier" <rgrandidier@.discussions.microsoft.com> wrote in message
news:E0B96D78-C2B6-4A46-BE08-E7E7B7FD1893@.microsoft.com...
> I am dynamically adding an HtmlInputHidden element with different values.
> The problem is the first time I add it with a given value and submit it
then
> change the value within the Page_Load event it still has the original
value.
> I am guessing this has something to do with viewstate. I have turned off
> viewstate at the page level, but the issue still occurs. Any suggestions?
> The code is basic:
> HtmlInputHidden phihAction = new HtmlInputHidden();
> phihAction.ID = "hdnAction";
> phihAction.Value = ((short)pactAction).ToString();
> mfrmUser.Controls.Add( phihAction );
> pactAction is an enumeration that changes based on action (i.e. 1=Add,
2=Edit)
> Any help in understanding why it does what it does and how to work around
it
> would be greatly appreciated.
> --
> Robert

Please explain strange viewstate behavior...

I am dynamically adding an HtmlInputHidden element with different values.
The problem is the first time I add it with a given value and submit it then
change the value within the Page_Load event it still has the original value.
I am guessing this has something to do with viewstate. I have turned off
viewstate at the page level, but the issue still occurs. Any suggestions?

The code is basic:
HtmlInputHiddenphihAction = new HtmlInputHidden();

phihAction.ID = "hdnAction";
phihAction.Value = ((short)pactAction).ToString();
mfrmUser.Controls.Add( phihAction );

pactAction is an enumeration that changes based on action (i.e. 1=Add, 2=Edit)

Any help in understanding why it does what it does and how to work around it
would be greatly appreciated.

--
RobertRobert,

You need to check IsPostBack property befory assigning the value:

HtmlInputHidden phihAction = new HtmlInputHidden();

phihAction.ID = "hdnAction";
if (IsPostBack)
phihAction.Value = ((short)pactAction).ToString();
mfrmUser.Controls.Add( phihAction );

Eliyahu

"rgrandidier" <rgrandidier@.discussions.microsoft.com> wrote in message
news:E0B96D78-C2B6-4A46-BE08-E7E7B7FD1893@.microsoft.com...
> I am dynamically adding an HtmlInputHidden element with different values.
> The problem is the first time I add it with a given value and submit it
then
> change the value within the Page_Load event it still has the original
value.
> I am guessing this has something to do with viewstate. I have turned off
> viewstate at the page level, but the issue still occurs. Any suggestions?
> The code is basic:
> HtmlInputHidden phihAction = new HtmlInputHidden();
> phihAction.ID = "hdnAction";
> phihAction.Value = ((short)pactAction).ToString();
> mfrmUser.Controls.Add( phihAction );
> pactAction is an enumeration that changes based on action (i.e. 1=Add,
2=Edit)
> Any help in understanding why it does what it does and how to work around
it
> would be greatly appreciated.
> --
> Robert

Wednesday, March 21, 2012

please help i need help urgently

Hi

I am working on asp.net application using vb.net as its language

I want to displaysystem date in a textbox and enter the value into sql database when a button "submit" is clicked

how can do it?when ever this webpage is started the textbox should automatically take the date in the text box and when i click a button submit that date should enter into the sql database

how can i do this?

please help i have an urgent project to be submitted on this plzzzz

You can get the current date by using System.DateTime.Now, however, I suggest you go through the video's and tutorials fromhttp://asp.net/learn to learn how to use ASP.NET before starting on any "urgent" projects.


Hi,

In the Page Load event

first check

if(!ispostback)

then

textbox.text=datetime.now.tostring()

also same for the submit button accept send the value in the insert query rather then textbox


You can also implement it in database level by using getdate()(for SQL server) function in the insert query or stored procedure whatever used by you to insert the value in databaseYou can also implement it in database level by using getdate()(for SQL server) function in the insert query or stored procedure whatever used by you to insert the value in database.


You can also implement it in database level by using getdate()(for SQL server) function in the insert query or stored procedure whatever used by you to insert the value in database.


"please help i have an urgent project to be submitted on this plzzzz"#

sounds like homework..

Please help me about cookies

I keepkim_test_1001@dotnet.itags.org.yahoo.com in cookies when I get cookies value It show "kim_test_1001%40yahoo.com%2Ecom".
Can I decode "kim_test_1001%40yahoo.com%2Ecom" tokim_test_1001@dotnet.itags.org.yahoo.com.

thank you

Use the Unescape function in .Net

here's the MSDN explemation to help you understand what unescape to.

TheUnescapefunction returns a string (in Unicode format) that contains the contents of charString. ASCII character set equivalents replace all characters encoded with the%xx hexadecimal form. Characters encoded in%uxxxx format (Unicode characters) are replaced with the Unicode character with hexadecimal encodingxxxx.


I tried this:
var d;
d="kim_test_1001%40yahoo.com%2Ecom";
alert (unescape(d));
and the alert message gave the required value.
In serverside, you can use Server.UrlDecode whose JavaScript equivalent is unescape()

please Help me find out a way!

I want a client to enter a 'key' in a textbox and click a button. then the entered value will be used to search a table in the MS-SQL database. The corresponding value found from that table will be used to search a second table. Data found from the second table will be bounded to the datagrid control at the page where the client entered the 'key'. What will be the way to achieve this? What will be the SQL command??

I'm not sure if I'm able to describe the problem. I'm a new user of ASP.NET. So please help.

Ishtiaque.

A stored procedure like this will work:

CREATE PROCEDUREdbo.Example
@.key1varchar(255)
AS
DECLARE@.key2varchar(255)
SELECT@.key2 = key2columnFROMTable1WHEREkey1column = @.key1
--The select below will return your results so you can bind to your grid:
SELECT*FROMTable2WHEREkey2column = @.key2


Thank you Sharbel_.

I made a stored procedure as you suggested and used it by a 'drag and drop' method in my webform. But as I mentioned I am a novice user of ASP.NET, could not utilize the sqlConnection or sqlCommand that resulted of doing so. Would you please let me know how to do so?

Thanks in advance.


Hi,

using System.Data.SqlClient; at the top in the .cs file

Create the connection and the command objects in the page_load or in the button click as

SqlConnection sqlcn =new SqlConnection(connectionString);

sqlcn.Open();

//creating and initialising a command object

SqlCommand sqlcm =new SqlCommand();

sqlcm.Connection = sqlcn;

sqlcm.CommandType = CommandType.StoredProcedure;

sqlcm.CommandText = StoredProcedure name;

sqlcm.ExecuteNonQuery();

HTH.

Friday, March 16, 2012

Please Help me understand..

I want to create a page that pulls a specific record from a database based on the value passed from a Request.QueryString. If the value is not in the string then it uses a default value of 1(one). Here is what I have so far:

' Determine if a Content ID has been passed in the query string
' If so use it as a variable in our SQL string to grab content for the page
' Httpcontext.Request.Querystring("Content_id")

Sub BindHomeBodyData() ' GRAB CONTENT *************************

Const strSQL as String = "SELECT * FROM Content WHERE Content_ID = " & Httpcontext.Request.Querystring("Content_id")
Dim myCommand as New SqlCommand(strSQL, myConnection)
Dim myDA as New SqlDataAdapter()
myDA.SelectCommand = myCommand
Dim myDS as New DataSet()
myDA.Fill(myDS)
dlHomeBodyData.DataSource = myDS
dlHomeBodyData.DataBind()

End SubNot tested:

Dim Content_ID As Integer = 1

If Not IsNull(Request.QueryString("Content_id")) Then
Dim myRegEx As New RegEx("[^0-9]"), sContent As String = myRegEx.Replace(Request.QueryString("Content_id"), "")

If sContent <> "" Then
Content_ID = CInt(sContent)
End If
End If


to take what you have given me and place it into what I have. Sorry I am an extreme newbie. Here is what I have is there any way you could educate me here and show me how to write this out according to my example. Thanks a lot I appreciate it.

Sub BindHomeBodyData() ' GRAB CONTENT *************************

Const strSQL as String = "SELECT * FROM Content WHERE Content_ID = " & Httpcontext.Request.Querystring("Content_id")
Dim myCommand as New SqlCommand(strSQL, myConnection)
Dim myDA as New SqlDataAdapter()
myDA.SelectCommand = myCommand
Dim myDS as New DataSet()
myDA.Fill(myDS)
dlHomeBodyData.DataSource = myDS
dlHomeBodyData.DataBind()

End Sub