|
I have spun my wheels already. I have also looked pretty much everywhere for my specific use case but I have not been able to find anything that helps me. Please help.
I have an ASP.NET page embedding an unmanaged C++ OCX within the page using the following code.
[code]
<%@ Page AspCompat="true" Language="C#" AutoEventWireup="true" CodeBehind="Anywhere.aspx.cs" Inherits="Anywhere_Example_CSharp.AnywhereExample" %>
<!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>
<script runat="server" language="C#">
public void btn1_Click(object sender, EventArgs e)
{
mycontrol.AddUnconnected(10, 10, 0, 0);
}
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Add Person" OnClick="btn1_Click" />
<OBJECT id="mycontrol" style="WIDTH: 773px; HEIGHT: 488px" classid=clsid:F3AA9E66-A723-11D2-A17D-0060975A5AFA>
<PARAM NAME="_Version" VALUE="65536">
<PARAM NAME="_ExtentX" VALUE="20452">
<PARAM NAME="_ExtentY" VALUE="12912">
<PARAM NAME="_StockProps" VALUE="0">
</OBJECT>
<asp:Label id="lblMessage" runat="server" />
<asp:PlaceHolder id="phMyPlaceHolder" runat="server" />
</form>
</body>
[/code]
The control get displayed properly. The trouble comes when I try to get access to the API functions in the OCX with ID "mycontrol". What I wanna do is call the method mycontrol.AddUnconnected(0, 0, 0, 0) on the OCX. Unfortunately this is not working.
In fact if I have function
[code]
public void btn1_Click(object sender, EventArgs e)
{
mycontrol.AddUnconnected(10, 10, 0, 0);
}
[/code]
not commented out as shown, the page is not displayed whereas if I comment out the line
[code]
mycontrol.AddUnconnected(10, 10, 0, 0);
[/code]
The page is displayed and the control works fine, except I cannot call the API functions.
How do I make the control that has been embedded inside a page using the <object> tag as shown above accessible to my server side controls / and server side scripts?
Your help is appreciated.
Thanks,
Melody
|
|
|
|
|
Somebody sure has embedded a C++ OCX in ASP.NET. SOS.
I have found a way to do by using javascript injection but that is not adequate. And even if that worked I still have a problem with passing values that are set using JavaScript back to the server.
Example code below
<br />
<br />
protected void Page_Load(object sender, EventArgs e)<br />
{ <br />
{<br />
<br />
string ls_script = "<script language=\"JavaScript\">";<br />
ls_script += "\n";<br />
ls_script += "<!--";<br />
ls_script += "\n";<br />
ls_script += "function AddUnconnected() { ";<br />
ls_script += "\n"; <br />
ls_script += "\n"; <br />
<br />
ls_script += "var ocx = document.getElementById(\"progeny\"); \n"; <br />
ls_script += "if (ocx != null) { \n";<br />
ls_script += " var upn = ocx.AddUnconnected(0, 0, 0, 0); \n";<br />
ls_script += " var mom = ocx.AddPerson(upn, 2, 0); \n";
ls_script += " var pap = ocx.AddPerson(upn, 1, 0); \n";
ls_script += " ocx.SmartDraw();\n";<br />
<br />
<br />
ls_script += " var xml = document.getElementById(\"XMLSTRING\"); \n";<br />
ls_script += " if (xml != null) xml.innerText = ocx.GetXMLString(); \n";<br />
ls_script += "} \n";<br />
ls_script += "alert(\"Nuclear Family Created\"); \n"; <br />
ls_script += "}";<br />
ls_script += "\n";<br />
ls_script += "// -->";<br />
ls_script += "\n";<br />
ls_script += "</script>";<br />
this.Page.RegisterClientScriptBlock("AddUnconnected", ls_script);<br />
<br />
this.Button1.Attributes.Add("onclick", "AddUnconnected()"); <br />
} <br />
}<br />
|
|
|
|
|
Hi everyone, since I'm an ASP newbie, can you recommend a good article dealing with writing at the server side?? Take guest book postings as an example in which a page would write text from a text box down to a file in the server..
A quick tip about how to do it would be appreciated!
Thank you guys!
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
You can use standard C# code to write to flat files, but a guestbook is far more likely to write to a database.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks Christian,
Christian Graus wrote: You can use standard C# code to write to flat files,
Really?? And that would write at the server side not the client side?? Using the same read/write streams from IO??
I'll try it now, thanks Christian
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi all,
assuming that we have an FormView which is binded with an ObjectDataSource, which provide a List<myobject> list as SELECT result.
The list provided by the ObjectDataList is composed by some object of MyObject class, which is the following:
class MyObject
{
int a;
int b;
InnerObject oInner;
}
The InnerObject class is the following:
class InnerObject
{
int alpha;
string bravo;
}
I would like to bind the Text property on a asp:label object with the MyObject.oInner.bravo string, using the Eval().
Have you any idea about I can do it? Is it possible?
Thanks a lot
Regards
Federico
|
|
|
|
|
Yes, just bind to it as normal. Instead of binding to MyProperty, bind to oInner.bravo.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello Christian,
thanks for your reply. The Bind("oInner.bravo") works only with a Label in my FormView's ItemTemplate. If I try to use it in a DropDownList like the following:
<asp:dropdownlist id="ddlCategoriaCorsoEdit" runat="server" datasourceid="odsCategorie" datatextfield="Titolo" datavaluefield="ID" selectedvalue="<%# Bind("oInner.bravo") %>
I got a build error: "Unknow server tag" in the ASPX page
<uc1:visualizzacorso id="VisualizzaCorso1" runat="server" />
where VisualizzaCorso is my formview.
Have you any idea how it happens??
Regards
Federico
|
|
|
|
|
Hi,
I'm new to asp.net and using IIS in general.
I followed the steps at http://www.builderau.com.au/strategy/architecture/soa/Utilise-Web-services-in-the-real-world/0,339028264,339130846,00.htm[^]
- used wsdl.exe to generate a .cs file from the wsdl file.
- compiled the .cs file into a dll.
I installed IIS on my WinXP. I think it installed IIS 5.1. I tested sample asp.net vb and c# aspx code and it works fine.
My question is, where do I place the generated DLL? I have the sample.aspx that uses the DLL in the C:\Inetpub\wwwroot itself. I placed the DLL in this directory itself, but when I run the aspx, I get an error with the following line in aspx:
]]>
CS0246: The type or namespace name 'SampleNS' could not be found (are you missing a using directive or an assembly reference?)
It looks like it is not finding the DLL. Where am I supposed to place the DLL? I created a bin directory under C:\Inetpub\wwwroot and placed the dll there, but that didnt help either.
Can someone help?
Thank you so much.
--c_s_k
|
|
|
|
|
Actually, you can just add the proxy class to your webproject.. If you already compile it as a dll, you can add it as a reference in your webproject.. then it will be automatically copied to your bin folder..
|
|
|
|
|
I dont have a web project, developed in visual studio. I'm yet to learn that.
I compiled the dll manually, and created the aspx manually the following the instructions at the above links.
so all I have is a dll and a aspx file. I have built these manually and might have made mistakes.
Are there any other tutorials to do something similar?
thanks.
|
|
|
|
|
Actually, if you are using Visual Studio 2005 or 2008 Express then it is more easier for you to do that thing.. You can download it from this link http://www.microsoft.com/express/vwd/[^]
then, create the new webproject. Add your webservice as web reference in your web project..
|
|
|
|
|
Michael,
Thanks for the pointer. I have visual studio 2008. I will take a look on using it.
Meanwhile, can you take a look at the following and see if you can figure out what's going wrong?
This is what I am doing:
1. wsdl /out:LocalTime.cs /n:LocalTimeNS http://www.ripedev.com/webservices/LocalTime.asmx?WSDL
2. csc /t:library /out:LocalTime.dll /reference:System.Web.Services.dll LocalTime.cs
3. Place the DLL in C:\Inetpub\wwwroot\bin.
4. Place the following code in localtime.aspx and place it in C:\Inetpub\wwwroot
<code>
<![CDATA[<%@ Page language="c#" %>]]>
<![CDATA[<%@ Import Namespace="LocalTimeNS" %>]]>
<script language="C#" runat="server">
private void Page_Load(object sender, System.EventArgs e) {
LocalTime testService = new LocalTime();
this.txtTemp.Text = testService.LocalTimeByZipCode("40243");
}
</script>
<html><head>
<title>Builder.com Web Service utilisation example</title>
</head>
<body>
<form id="frmWSExample" method="post" runat="server">
<asp:textbox id="txtTemp" style="Z-INDEX: 101; LEFT: 224px; POSITION: absolute;<br mode=" hold=" />TOP: 64px" runat="server" />
<asp:label id="lblOutput" style="Z-INDEX: 102; LEFT: 32px; POSITION: absolute;<br mode=" hold=" />TOP: 64px" runat="server" width="176px">The current time is:</asp:label>
</form></body></html>
</code>
Note that the codeproject server is adding CDATA and adding an extra space in each html tag above. The code I am using is following the example at http://www.builderau.com.au/strategy/architecture/soa/Utilise-Web-services-in-the-real-world/0,339028264,339130846,00.htm
5. Access the aspx using the url http://localhost/localtime.aspx
6. This gives the error refering to the line 2 in the code above(Import Namespace="LocalTimeNS"):
CS0246: The type or namespace name 'LocalTimeNS' could not be found (are you missing a using directive or an assembly reference?)
Thanks!
--c_s_k
|
|
|
|
|
I figure out what was needed to get this working. I created a sample site using visual studio 2005 and looked the site properties.
- create a folder called foo
- place the localtime.aspx in foo
- create a foo\Bin and place the dll in foo\Bin
- In the IIS manager, open the properties of foo under that is under the default site
- Under the Directory tab, create an application for this folder.
- Under the ASP.NET, change the version number from 1.xxx to 2.xxx.
With this, http://localhost/foo/localtime.aspx works fine.
|
|
|
|
|
I have used datagrid to display data on a web page. Does anyone know how to use the sleep function in vb.net to display data using time intervals.
for example first entry came in at 16:02:01 and the second at 16:02:21 instead of displaying both entries at once i want it to display the first entry then wait 20 secods to display the second entry.
I hope i have made the problem clear.
|
|
|
|
|
You need to buy a book on ASP.NET and read it, so that you understand what it is, and how it works. Your VB.NET code runs on the server, there's never a good reason to use sleep there. You can write a timer in javascript, which is the language that runs on the client, which uses AJAX or just forces a refresh to update your data.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I dont think you understood the problem. my fault!!! a refresh will only display all the data and also display new entries into the db. What i want to do is to display all entries one by one depending on a time attribute. Therefore after the first record is displayed , i want it to sleep for the number of seconds it took for the next record to be displayed. hope this is a lot clearer
|
|
|
|
|
You can use Ajax to do like that.
1. Get all data from database
2. Execute one JS fuction to display one record and set the timer
3. If the timer event is fired, you can call the server-side function to get the another record. then, show this record in your webpage. then, change the timer..
I'm not so sure why you want this way..
For me, I tried one similar scenario in my project but I didn't use the dynamic time interval to display the record. I used the static time interval to display the record one by one..
|
|
|
|
|
i dont quite understand the way you did your project. can you please point me in the right direction as to how i can achieve this. And also does it mean i cant use datagrid?
|
|
|
|
|
solarthur01 wrote: does it mean i cant use datagrid?
I didn't use the Datagrid because I don't think the standard Datagrid can handle this kinda scenario.
solarthur01 wrote: i dont quite understand the way you did your project.
Let's say there are 10 records that suppose to be displayed on my page. If I bind those records to GridView then all records will be shown after postback. This is what I don't want. So, I used the DIV and Yahoo animation to display the records with fading effect one by one after 3 or 5 secs.
|
|
|
|
|
You don't need to use AJAX, but you do need to use Javascript. AJAX in action is a good AJAX book. What he means is, no matter what, if you're going to use a datagrid, unless you set it up to create hidden rows and use javascript to show them, what you want to do is probably incompatible with using a data bound control. I'd use a repeater, to give you the control you need over the layout so you can set stuff out to be hidden by default and show it via a script.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
A bit of background before my problem:
We're doing a security overhaul of our internal applications. We've decided that most pages will have 3 forms of security: read-only, partial input, and full control. The read-only and full controls portions are fairly self-explanatory. The partial input version of the page is controlled by the security roles we setup for the various users. One person may have the ability to edit a particular field, while another doesn't.
We receive complaints about hard to read disabled drop down lists. As of right now we have two solutions: javascript that disables clicking on the control, or a custom control that changes the dropdown to a label when it is disabled.
And now the problem:
I'm working on this second option. I created a class that inherits from the DropDown class and created a new property called ChangeToLabel. Code follows:
<br />
Public Class DropDownDisable<br />
Inherits DropDownList<br />
<br />
Dim lbl As New Label<br />
<br />
Public Property ChangeToLabel() As Boolean<br />
Get<br />
Dim s As Boolean = CBool(ViewState("ChangeToLabel"))<br />
Return s<br />
End Get<br />
Set(ByVal value As Boolean)<br />
<br />
If value = False Then<br />
Me.Visible = True<br />
'Me.Enabled = True<br />
lbl.Visible = False<br />
Else<br />
'lbl.Style.ToString = Me.Style.ToString<br />
lbl.CssClass = Me.CssClass<br />
lbl.Width = Me.Width<br />
lbl.Height = Me.Height<br />
lbl.Visible = True<br />
lbl.Text = MyBase.SelectedItem.Text<br />
lbl.ID = Me.ID & "_disabled"<br />
lbl.BorderColor = Color.FromKnownColor(KnownColor.InactiveBorder)<br />
lbl.CopyBaseAttributes(Me)<br />
lbl.Enabled = True<br />
lbl.TabIndex = -1<br />
Me.Visible = False<br />
Me.Parent.Controls.Add(lbl)<br />
End If<br />
End Set<br />
End Property<br />
<br />
End Class<br />
<br />
The problem occurs when the page containing this control posts back. The newly created labels are getting lost. The even stranger problem is that not every label is disappearing. So far, all of the controls that disappear are in a third-party MultiPage control (we use ComponentArt). We run the security methods on every postback, so I'm assuming the labels are on the page in the appropriate places, and that they're just losing their text values. Thanks for any help you can give me.
Tom
|
|
|
|
|
Have you tried setting breakpoints to ensure they are created on a postback ? If it only happens in a third party control, have you asked them ? Their control could be doing something that only they can help you with.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Well, my problem was my own dumb fault. As it turned out, I was doing things in the wrong order. I was creating a new label every time the control was built, instead of only creating a new label when the property was called. Now everything works great. Huzzah!!
|
|
|
|
|
Is there a way to test to see if the compare validator in JavaScript? My issue is I have a calendar extender and the clientside code calls its corresponding update. The problem lies that if the validator returns true that I don't want to the Update to occurs.
Here's a snippet.
function CalStartChanged()
{
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm._doPostBack('UpdatePanel2','');
}
<asp:UpdatePanel ID="UpdatePanel2" runat="Server">
<ContentTemplate>
<asp:TextBox runat="server" id="txtStartDate" Width="100px" CssClass="LeftSelectionSmall"/> <img src="Images/Calendar.jpg" id="btnStartDate" alt="Choose start date." runat="Server"/>
<ajaxToolkit:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtStartDate" Animated="False" PopupButtonID="btnStartDate" OnClientDateSelectionChanged="CalStartChanged"/>
</ContentTemplate>
</asp:UpdatePanel>
Protected Sub UpdatePanel2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles UpdatePanel2.Load
If scriptManager1.IsInAsyncPostBack And scriptManager1.AsyncPostBackSourceElementID = "UpdatePanel2" Then
dgresults.DataSource = oData.FillDataTable(StrQueryReturn(txtStartDate.Text, txtEndDate.Text, lstShift.SelectedValue, lstSpecies.SelectedValue, lstPackType.SelectedValue))
dgresults.DataBind()
'Put the sql in the cheat box
CB.Text = StrQueryReturn(txtStartDate.Text, txtEndDate.Text, lstShift.SelectedValue, lstSpecies.SelectedValue, lstPackType.SelectedValue)
End If
End Sub
|
|
|
|