|
Hi peacefulmember,
I have to apologize. I use cookies without my knowledge
Now that I know that I use cookies I found out that there is a cookie in which the session id is stored. I save now the value which I wanted to store in the session also in the cache with following statement:
<br />
Cache[Session.SessionID + "_MyKey"] = Value;<br />
The difference to just saving it in the session is that the cache is available every time and the cookies are already present at the time I need to get the value. So in my VirtualFile I added following code to retrieve the value again:
<br />
if (HttpContext.Current.Request.Cookies["ASP.NET_SessionId"] != null) {<br />
value = (String)System.Web.Hosting.HostingEnvironment.Cache[HttpContext.Current.Request.Cookies["ASP.NET_SessionId"].Value + "_MyKey"];<br />
}<br />
That solved the problem for me. It's kind of a workaround. I would have preferred the "Session-Solution" but as the Session is not filled that time I have to solve it this way.
Thanks
Oliver
|
|
|
|
|
I have user control with some standard HTML tags. On one of my HTML button tag I want to perform a javascript validation (a Hello test function for now).
I cannot figure out how can I trigger this function from with in my user control on this HTML button tag click event or on usecontrol's click event.
Thanks in advance.
Partial Class MyUserControl
Inherits System.Web.UI.UserControl
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim js As StringBuilder = New StringBuilder()
js.Append("<script language=JavaScript>")
js.Append("function Hello() { ")
js.Append(" alert ('Hello'); }")
js.Append("</script>")
If (Not Page.ClientScript.IsStartupScriptRegistered("MyScript")) Then
Page.ClientScript.RegisterStartupScript(Me.GetType(), "MyScript", js.ToString())
End If
End Sub
End Class
|
|
|
|
|
Sorry, I messed up the subject earlier. But I meant to wish everybody. HI.
|
|
|
|
|
The easiest way is to use a custom validator, which can be made to call any function you like.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian,
Custom Validator!! Sorry, I am not too expert with .net.
Could you please explain this with an example?
Thanks
|
|
|
|
|
Since your javascript function is not dynamic, it's better to write in page itself than writing from code behind. Write your javascript function on usercontrol.
Assume you have a button tag like
<input type="button" id="Btn" OnClick="Hello();"> . This will invoke Hello() method when button is clicked.
|
|
|
|
|
I do not want to write my javascript in the page itself. Validations are different in the case of different parameters passed to the user control.
What do you mean by that javascript function is not dynamic..How can I make it dynamic, if that can lead me to the functionality that I want? So, far I was thinking my javascript is dynamic as I have it in page_load and it will be written to the page after form tag is rendered on the page side.
Thanks
|
|
|
|
|
Well, I have one more question. Like I mentioned based on user control's parameter value I need to perform different client side validation.
I could set parameter of user control (have a property, suggest if there is another better way), but how can I use this property value in Javascript?
Thanks for bearing with me.
|
|
|
|
|
just reply the triggering code u hav...
Sarith...
|
|
|
|
|
Hi,
Here is the similar query, that I need:
SELECT News.NewsID, News.Headline, Images.ImageID<br />
FROM News INNER JOIN<br />
Images ON News.NewsID = Images.NewsID<br />
WHERE (News.Enabled = @Enabled) AND (Images.Favourite = @fave)
But this gives only those headlines that have there images, but I need all the headlines, and if they have images, then to get the favorite imageID, because they can have more than one image and only one of them is favorite.
thx
|
|
|
|
|
Do an outer join, so you get the columns you want, plus those where the image doesn't exist.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I tried all kinds of outer join (right, left, full), but it is still gives me only those columns that are both enabled and have images, but I also need those that don't have images, it should give me NULLs, if there is no image on images table.
thank you
|
|
|
|
|
I'm trying to select data from an MS Access Db and display it in a asp.net web form, but i'm getting the follwing compiler error message:
Compiler Error Message: CS0117: 'ASP.user_default_aspx' does not contain a definition for 'AccessDataSource1_Selecting'
Line 29: <asp:accessdatasource id="AccessDataSource1" runat="server" datafile="~/App_Data/Members.mdb"
key:-="" x="asp"
<code="">
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="User_Default" %>
<x:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Members.mdb"
OnSelecting="AccessDataSource1_Selecting" SelectCommand="SELECT [USERNAME], [GALAXYNO], [SOLARNO], [PLANETNO], [LASTLOGIN] FROM [Members]">
</x:AccessDataSource>
<x:DataList ID="DataList1" runat="server" BackColor="Black" DataKeyField="USERNAME"
DataSourceID="AccessDataSource1" Font-Bold="False" Font-Italic="False" Font-Names="Arial"
Font-Overline="False" Font-Size="12pt" Font-Strikeout="False" Font-Underline="False"
ForeColor="White" HorizontalAlign="Center" RepeatColumns="5" CellPadding="2" CellSpacing="10">
<ItemTemplate>
Username:
<x:Label ID="USERNAMELabel" runat="server" Text='<%# Eval("USERNAME") %>'></x:Label><br />
Galaxy:
<x:Label ID="GALAXYNOLabel" runat="server" Text='<%# Eval("GALAXYNO") %>'></x:Label><br />
Solar system:
<x:Label ID="SOLARNOLabel" runat="server" Text='<%# Eval("SOLARNO") %>'></x:Label><br />
Planet:
<x:Label ID="PLANETNOLabel" runat="server" Text='<%# Eval("PLANETNO") %>'></x:Label><br />
Last Login:
<x:Label ID="LASTLOGINLabel" runat="server" Text='<%# Eval("LASTLOGIN") %>'></x:Label><br />
<br />
</ItemTemplate>
<HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
Font-Underline="False" HorizontalAlign="Center" VerticalAlign="Middle" />
</x:DataList>
Regards, Michael
|
|
|
|
|
BigtimeOneEleven wrote: önSelecting="AccessDataSource1_Selecting"
BigtimeOneEleven wrote: Compiler Error Message: CS0117: 'ASP.user_default_aspx' does not contain a definition for 'AccessDataSource1_Selecting'
Seems to me that this method does not exist in your page.....
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hey guys, whats up ?
I want to connect to SQL in ASP.NET
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyDB.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
In my main form I have this code:
I have added a SQLDatasource for my connection string !
MyConn.ConnectionString = SqlDataSource1.ConnectionString;<br />
MyConn.Open();<br />
MyCmd.CommandText = "SELECT UserName from UserT where UserName = " + UserName_tb.Text;
string CheckName = (string)MyCmd.ExecuteScalar();
in this line I get this error !
ExecuteScalar: Connection property has not been initialized.
|
|
|
|
|
The error is self explanatory.
You havent set the connection property for "MyCmd" i.e. sqlCommand.
Not very sure about VB syntax, but you need to do something like.
"MyCmd.Connection = MyConn "
It shud solve problem.
|
|
|
|
|
Thanx dude ! you ve been very helpful !
Mr.K
|
|
|
|
|
Most welcome Mr K.
Since am quite new to scores here.. wud really appreciate if you grade my reply and articles.
|
|
|
|
|
I have made a user control ( text.ascx) with a text box (txtUserControl) and a button (btnUserControl) .
<br />
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="test.ascx.cs" Inherits="WebApplication1.test" %><br />
<br />
<asp:TextBox ID="txtUserControl" runat="server"></asp:TextBox><br />
<br />
<asp:Button ID="btnUserControl" runat="server" Text="Button" /><br />
<br />
Now i load this usercontrol dynamically on (default.aspx) into two panels:
<br />
public partial class _Default : System.Web.UI.Page<br />
{<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
test tst = Page.LoadControl(@"~\test.ascx") as test;<br />
pnlDefaultOne.Controls.Add(tst);<br />
}<br />
<br />
protected void btnDefault_Click(object sender, EventArgs e)<br />
{<br />
test tst = Page.LoadControl(@"~\test.ascx") as test;<br />
pnlDefaultTwo.Controls.Add(tst);<br />
}<br />
}<br />
Now, the question is about the beahviour of textbox (txtUserControl), and its viewstate.
When i click btnDefault.. it loads the userControl in panelTwo.
now when i enter values in both the textboxes (each of a usercontrol), and click the btnDefault, the value in the first control (the one loaded at page_load) is persisted, while in the other one which was loaded in btnEvent is NOT.
i have read decent enough abt page cycle and am aware abt rendering, viewstate, postBackData.
BUt cant really figure out the reason behind this.
Any comment on the same will be of help.
Thanks in advance.
|
|
|
|
|
Good day my friends.
I am having a few issues with dates. It's like this.
Textbox auto populates on page load with todays date in english format (day/month/year).
Then when I go to use this and stuff it in the database I get an error, pretty much cos the date is in the wrong format.
So I added in the code to alter this to the correct (American) format for the db. This worked fine until code was passed over to my web server and then it stopped being happy about the format of the date from the text box.
How do I get around this issue without getting to complex. Code is as follows
<br />
Dim ExpiryDate As String = Convert.ToDateTime(ExpiryDateTB.Text.Trim()).ToString("MM/dd/yyyy")<br />
|
|
|
|
|
When updating the database do as follows I'm a C# guy but here is close to what you should do.
Dim datetime d;
if datetiem.tryparse(this.ExpiryDateTB.Text, out d) = true
sqlparameter prm = new sqlparameter("@yourParam", d)
do updates.
I didn't get any requirements for the signature
|
|
|
|
|
Use a UTC format to store your datetime. That way you eliminate the differences in culture.
Also, I think you could choose a more appropriate subject than, God dam dates!! It's offensive and does not follow the guidelines. See How to get answers post at the top.
only two letters away from being an asset
|
|
|
|
|
Hi All,
I have developed a web application using C#.NET and ASP.NET
I have uploaded web Application to our Server.The Url is http://www.xtravels.com .We can access this url from outside.But the problem is We can not access this from inside the Server.
Can any tell me how to fix that problem. I have tried it to solve. But can't.
Thanks in advance.
|
|
|
|
|
pubududilena wrote: I have uploaded web Application to our Server.The Url is http://www.xtravels.com .We can access this url from outside.But the problem is We can not access this from inside the Server.
oh. inside the Server?? How did you go inside the Server? I guess your server might be really large so people can go inside the System Unit.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Just try the local IP of the server machine.
|
|
|
|