|
below is code
protected void gotoCart(object sender, EventArgs e)
{
ImageButton btn = (ImageButton)sender;
double Price = double.Parse(((Label)btn.Parent.FindControl("Price")).Text);//.Substring(8));
string ProductName = ((HyperLink)btn.Parent.FindControl("hlnkProductName")).Text;
string ImagePath = ((System.Web.UI.WebControls.Image)btn.Parent.FindControl("imgProduct")).ImageUrl;
string ProductID1 = ((HtmlInputHidden)btn.Parent.FindControl("hdnid")).Value;
string ParentID = ((HtmlInputHidden)btn.Parent.FindControl("hdnParentID")).Value;
int ProductID = Convert.ToInt32(ProductID1.Substring(1));
if (Profile.Cart == null) // here at this line it shows error
{
Profile.Cart = new shopping.ShoppingCart();
}
Profile.Cart.Insert(ProductID, Price,0, 1, ProductName, ImagePath);
Response.Redirect(ResolveUrl("~") + "Shopping_Cart/ShoppingCart.aspx");
}
|
|
|
|
|
I would be interested to know if you ever found a solution. I too have recently come across this very same issue when trying to access the Profile object. I dont think it is related to this article some configuration issue on the server - look up MOSS and profile null.
|
|
|
|
|
While try to execute this code i get an error message " Invalid attempt to call Read when reader is closed."
Public Shared Function GetLMSSettings() As Hashtable
Dim h As Hashtable
h = CType(DataCache.GetCache("GetLMSSettings"), Hashtable)
If h Is Nothing Then
h = New Hashtable
Dim dr As IDataReader = SqlDataProvider.GetLMSSettings
While dr.Read()
If Not dr.IsDBNull(1) Then
h.Add(dr.GetString(0), dr.GetString(1))
Else
h.Add(dr.GetString(0), "")
End If
End While
dr.Close()
DataCache.SetCache("GetLMSSettings", h)
End If
Return h
End Function
|
|
|
|
|
befor below line you must check dr is nothing
While dr.Read()
|
|
|
|
|
c# .net 2.0 web application.
I have tried following code.It is working fine in Server box (I have created vitrual direcory for record folder in c: drive "),
but it not working in client box.
c:\\record\\record.wav"
Code
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;
using Microsoft.VisualBasic.Devices;
using Microsoft.VisualBasic;
using System.Runtime.InteropServices;
public partial class Recording : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);
protected void btnRecord_Click(object sender, EventArgs e)
{
mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
mciSendString("record recsound", "", 0, 0);
}
protected void btnSaveStop_Click(object sender, EventArgs e)
{
mciSendString("save recsound c:\\record\\record.wav", "", 0, 0);
mciSendString("close recsound ", "", 0, 0);
Computer c = new Computer(); c.Audio.Stop();
}
protected void btnRead_Click(object sender, EventArgs e)
{
Computer computer = new Computer();
computer.Audio.Play("c:\\record\\record.wav", AudioPlayMode.Background);
}
}
Thanks,
Bruze
|
|
|
|
|
This is the basics of ASP.NET. If you play audio using Computer.Audio.Play it will always run in the server.
What you have to do is to download the wav file to the client and then invoke the browser media object installed to run your wav file.
For simplicity you can also use
Body BgSound ="~/record.wav"
I recommend to read basic books before you do programming in Web Environment, as there is some problems in the basics of this environment. Hope you understand.
Also on your problem if you are using BgSound or anything, always refer to the Virtual path, as Physical path of your server is different from the clients.
|
|
|
|
|
Thanks For Your Reply.
Actually, First of all I want to record the audio and Save into Client box using browser.Once I recorded the audio file then Upload into Server folder.
Thanks,
Bruze
modified on Monday, September 21, 2009 5:29 PM
|
|
|
|
|
Yes. Say you upload a file into the server
say abc.wav
save this file into a directory which is within the virtual path. say c:\mywebsite\xyz folder.
so that you can call
http://yourserver.com/xyz/abc.wav
Now create your webpage such that it plays audio using this path.. not your original physical path.
Finally take any of the different steps mentioned here to play your sound in the browser:
http://www.phon.ucl.ac.uk/home/mark/audio/play.htm[^]
Hope you understand this.
|
|
|
|
|
I got it. Thank you So much for your reply
|
|
|
|
|
hi
through this code i am recording audios and listening locally but I am unable to record audios on online(production server).its showing empty file.recording not happening there.
Please suggest me
my code as follows
protected void btnSaveStop_Click(object sender, EventArgs e)
{
shortPath = Server.MapPath("~/Audios/" + txtTag.Text + ".wav");
formatShortPath = string.Format("save recsound \"{0}\"", shortPath);
mciSendString(string.Format("{0}", formatShortPath), null, 0, 0);
mciSendString("save recsound ", "", 0, 0);
mciSendString("close recsound ", "", 0, 0);
Computer c = new Computer(); c.Audio.Stop();
}modified on Friday, March 12, 2010 1:08 AM
|
|
|
|
|
I found that in my webpage, once the alert messagebox (as follows) is shown then some control styles (such as, location, font size and so on)
are changed in a unexpected way. what is the reason then? anyone suffered this problem before?
Response.Write("<script>alert(sth is here!')</script>");
|
|
|
|
|
I think this is not good practice to write the response. Rather use
this.ClientScript.RegisterStartupScript(this.GetType(), "myscript", "alert('sth is here!')", true);
RegisterStartupScript is there to write javascript output to the client, so why use Response.Write.
|
|
|
|
|
Hi,
The situation is this:
I would like to have an static method in some class of the Models library like this
static User GetCurrentUser()
Which takes a cookie in the user ("currentUserId") and returns the User retrieved from the db..
The problem: I cant have access to the cookies (to the "Request" class) from the Model lib.
So what other solution can I use?
Should I make that method in the Controllers library? IF i dont add a view to a method of a controller class then that method wont be an action?
ALSO: The method needs to be used from other controllers.. so.. is that possible?
|
|
|
|
|
Why dont you use Static Property...
HttpContext.Current.Request.Cookies
This will do the trick...
|
|
|
|
|
As a basic tenet of the MVC pattern the model should not need to know about such things.
only two letters away from being an asset
|
|
|
|
|
Separation of concerns is a reason to use the MVC pattern. By trying to use the Request object in your model you are violating the tenets of MVC.
There is not a one-to-one correlation between views and actions. You can have an action that redirects to another view or renders another view.
Create a BL class that has the GetCurrentUser method and call it from the controllers as necessary.
only two letters away from being an asset
|
|
|
|
|
I have a page with ultrawebgrid. in the first cell of the grid has a hyperlink. when you press the hyperlink opens a new page but when it loads stays back and shows the first one.
I want to focus on the second page.
please help.
|
|
|
|
|
Add this code to the second page:
<script type="text/javascript">
function setFocus()
{
document.getElementById('yourcontrolid').focus();
}
</script>
Now in the second page
<body onload="javascript:setFocus();">
Thus the focus will be set when body is fully loaded...
|
|
|
|
|
But I was little bit confused because he was asking for Focus on Page.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
This is the most weird thing ... If he ever thought of this, its impossible(AFAIK). How can one have focus on a blank page which is not even
document.body.contentEditable='true';
document.designMode='on';
focus moves from control to control based on the Tabindex specified, and after it finishes all form elements it goes to addressbar etc...
|
|
|
|
|
Hi all,
Im using asp bulleted list control with ajax paging extender. I want to display the bullets flow in horizontal direction. can any one help me.
it displays like .asaa
.sadsa
.asasa
Please help me.
|
|
|
|
|
You can use CSS to control the elements on your page.
only two letters away from being an asset
|
|
|
|
|
anu_anu wrote: it displays like .asaa
.sadsa
.asasa
Means U want To Display It
.asaa .sadsa .asasa
or the Format U asked
I am Bit Confused
http://www.asp.net/LEARN/ajax-videos/video-145.aspx[^]
I think the above is Not Ur Answer Right..!
If It Helps Click It as Answer
|
|
|
|
|
You need to display horizontal..
use
display:inline
For Example :
<style>
.bulletstyle
{
padding-left:10px;
}
.bulletstyle li
{
display:inline;
}
<style>
<asp:BulletedList runat="server" ID="blt" CssClass="at-red">
<asp:ListItem>Item1</asp:ListItem>
<asp:ListItem>Iten2</asp:ListItem>
<asp:ListItem>Item3</asp:ListItem>
</asp:BulletedList>
The output will be <br />
Item1 Item2 Item3
|
|
|
|
|
and 7 hours later...
only two letters away from being an asset
|
|
|
|