Showing posts with label file. Show all posts
Showing posts with label file. Show all posts

Wednesday, March 28, 2012

Accordian - How to refer to contained controls in code behind?

Hi,

If i put regular asp.net controls into an accordian pane they are not visible in the code behind file. In other words i cant get mydropdown.selectedvalue if mydropdown is contained in an accordian pane because the compiler will complain that mydropdown doesn't exist? My work around has been to put content into user controls and put the ascx's into the content panes but is this standard practise?

Thanks

Richard

Hi Richard,

Since the AccordionPanes can be databound, they implement theINamingContainer interface and you're unable to access them directly in your code behind. You can work around this withDropDownList list = MyAccordion.FindControl("MyDropDown") as DropDownList;.

Thanks,
Ted

Accessing inherited behavior properties

Hello,

I've created a new extender who's behavior class in the javascript file inherits from an existing control (in this case the cascading drop down) and registered it like so:

CustomCascadingDropDown.CustomCascadingDropDownBehavior.registerClass(
'CustomCascadingDropDown.CustomCascadingDropDownBehavior', AjaxControlToolkit.CascadingDropDownBehavior
);

I'm listening for the selectedValue property change event to occur so that I can access the resulting value and operate on it but when I try to access it from my inherited behavior class as this._selectedValue I get a null value. If I try using the callBaseMethod method to access the property accessor I get a different exception. How do I access inherited properties?

Also, what is the correct procedure for attaching to property changed events? I assumed from other posts that is by using this.add_propertyChanged(handler) but is this correct? How does this attach itself to a specific property or does it just enumerate through all properties that have been changed?

Thanks in advance.

Hi,

can I see the code that you're using to handle the event?


Sure thing... thanks for the help by the way.

The code below is just a test. I just want to see if I can access the inherited property.

First I attach a handler to listen for the property changed event in the initialize method of my custom behavior:

initialize : function() {
PersistentCascadingDropDown.PersistentCascadingDropDownBehavior.callBaseMethod(this, 'initialize');
this.add_propertyChanged(this.test);
},

Again, I'm not sure if this is the correct way to attach a handler to the propertyChanged event. It is only an assumption (how exactly do I target only one of the many properties that raise propertyChanged events?).

Next is my event handling method.

test : function (sender, args)
{
if (args._propertyName == "SelectedValue")
{
// Throws an exception
alert(PersistentCascadingDropDown.PersistentCascadingDropDownBehavior.callBaseMethod(this, 'get_SelectedValue'));

// Alerts as undefined
alert(typeof(this.get_SelectedValue));

// Alerts that object doesn't support method
alert(this.get_SelectedValue());
}
},

Thanks again for your help.

Monday, March 26, 2012

Access not running webservice methods with only wsdl file

Hello!

I'm new to web services. I'm using Visual Studio 2005, I'm developing a web app (c#). This application will use a java web service (hosted by tomcat) on the local machine. This webservice need some config to run, but on my developer machine i cannot make this configs.
My question: I cannot run the webservice, so I cannot add it to my "Web references", so I cannot insert the function calls into my code. BUT I have a wsdl file. So, is there any way to add a web reference to my code with this wsdl? (It will not work, but i can build my project)

Many thx

Hi,

Thank you for you post!

Here:

#Web Services Integrationhttp://msdn2.microsoft.com/en-us/library/aa478995.aspx

<quote>

In order to add a Web Reference to a .NET Framework-based Web service client, the target Web service must have a WSDL document available. Apache SOAP 2.2oes not contain any support for WSDL.

</quote>

Apache AXIS, also known as Apache SOAP 3.0, supported generating WSDL files.

We have just tested and VS can add web reference using a local WSDL file.

BTW,Wsdl.exe accepts the path to the wsdl file to generate a proxy.http://msdn2.microsoft.com/en-us/library/7h3ystb6(VS.80).aspx

If you have further questions,let me know.

Best Regards,


Hy!

Thanks for your answer. I solve it strange way: I put the wsdl file to my localhost, so i can add it to my web reference list. It did not work, but i could build my project.


Hi,

I told you in my last reply:

We have just tested and VS can add web reference using a local WSDL file.

So that is the answer:)

Happy coding.

Saturday, March 24, 2012

about file upload2

Hi,

I have a fileupload control inside update panel however I don't need to upload any file I just need the file path and filename etc...

eventhough I can see it pastes the path inside the fileupload text part, I can't read it programmatically..

Thankss.

Why do you need the path to a file on the client computer? You can't read a file from the client computer anyway. What are you trying to achieve?


Dim instance As FileUploadDim value As Stringvalue = instance.FileName
.....................
 FileUpload.FileName:Gets the name of a file on a client to upload using theFileUpload control.

gridview:

Dim instance As FileUploadDim value As Stringvalue = instance.FileName
.....................
 FileUpload.FileName:Gets the name of a file on a client to upload using theFileUpload control.

Note that the original posted wanted the filename AND the path..


alexdresko:

Why do you need the path to a file on the client computer? You can't read a file from the client computer anyway. What are you trying to achieve?

This question reminded me how dumb I am :) thanks..

Well I'm coding a webmail interface and my mail server COM API asks for the path but this path is my server's path not the clients :D ok..

But if I know the path somehow; couldn't I upload the file programmatically? without fileupload control, I mean ok it ease the life but if it doesn't work inside an update panel how can I come up with?

Thanks for the reply..


No, you have to use the fileupload control. When the page posts back, you can save the file they uploaded to your server and from THAT you can determine the path to pass to your COM API.

Make sense?


Yes got it;

Thanks..

So is there anyway to do it with updatepanel?


No. You have to wrap your fileupload control within another updatepanel and set EnablePartialRendering = False. Supposedly there are other workarounds, and I know there is at least one third party AJAX enabled upload control, but the built-in fileupload control doesnt work with ajax..


Thanks for the reply;

Do you mean EnableViewState=False?? cause I couldn't find such property (EnablePartialRendering=False)

abortPostBack(); is not working..

Hi, I

I have written a javascript file as

Sys.Application.add_load(ApplicationLoadHandler)

function ApplicationLoadHandler(sender, args)

{

Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(CheckStatus);

}

function CheckStatus(sender, args)

{

var prm = Sys.WebForms.PageRequestManager.getInstance();if (prm.get_isInAsyncPostBack() & args.get_postBackElement().id =='CancelRefresh')

{

alert('cancelling');

prm.abortPostBack();

alert('cancelled');

}

}

if(typeof(Sys) !=="undefined") Sys.Application.notifyScriptLoaded();

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

I have written this to cancel my dropdown list postback But request is not cancelling.

My .aspx code.. is

<formid="form1"runat="server">

<asp:ScriptManagerID="ScriptManager1"runat="server">

<Scripts>

<asp:ScriptReferencePath="Cancel.js"/>

</Scripts>

</asp:ScriptManager>

<div>

<asp:UpdatePanelID="UpdatePanel1"runat="server">

<ContentTemplate>

<asp:DropDownListrunat="server"ID="ddl_testing"OnSelectedIndexChanged="ddl_testing_SelectedIndexChanged"AutoPostBack="True">

<asp:ListItemText="Manoj"></asp:ListItem>

<asp:ListItemText="Atul"></asp:ListItem>

<asp:ListItemText="Punit"></asp:ListItem>

</asp:DropDownList>

<asp:LabelID="Label1"runat="server"Text="Label"></asp:Label><br/>

<br/>

<asp:ButtonID="CancelRefresh"runat="server"Text="Cancel"/>

</ContentTemplate>

</asp:UpdatePanel>

</div>

</form>

While my .cs code is as follow..

protectedvoid Page_Load(object sender,EventArgs e)

{

Label1.Text = ddl_testing.SelectedItem.Text;

}

protectedvoid ddl_testing_SelectedIndexChanged(object sender,EventArgs e)

{

System.Threading.Thread.Sleep(2000);

Label1.Text = ddl_testing.SelectedItem.Text.ToString();

}

}

But my ajax request is not cancelling on clikcking cancel button ..Can anybody tell me why..

Thanks in advance..

Since the Cancel button resides in the UpdatePanel it appends the NamingContainer in the ID.
Try indexof instead of exatct match:

args.get_postBackElement().id.indexOf ('CancelRefresh') > -1

Wednesday, March 21, 2012

a issue in <atlas:UpdatePanel>:do not work with .css file in format of absolute path

i found a issue in <atlas:UpdatePanel> control, under <ContentTemplate> control, we usually put lots of html control or server control, withclass attribute orcssclass attribute.

if the .css file is in a format ofabsolute path like below

<link type="text/css" rel="stylesheet" href="/myWeb/css/RichClientUI.css"/
then the partial render html tagcan not apply style setting defined in .css file.

if the .css file is in a format of relative path like below

<link type="text/css" rel="stylesheet" href="../../css/RichClientUI.css"/>

then the partial render html tagcan apply style setting defined in .css file.

i think this should a bug. coz in web design, we usually use a method like <%=Util.GetApplicationPath%> to get a real web app path against a IIS Website, so that we can deploy our web app under awebsite or avirtual directory without changing any resource (e.g css/js/gif/jpg/etc.) path.-->

you should try to use the "~" character in your path

for example:
<img src="http://pics.10026.com/?src=~/Images/myimage.gif" runat="server"> this would start the path at your application root for the website or virtual directory then take you to the images folder then of course display your image...


the "~" character is very useful, but it has a restriction when use. coz it always renderrelative web application root path based onthe same web server. in web farm condition, we usually require absolute resource path. further, the absolute resource path maybe dynamically generated according some business logic, so this is why we need a static method like <%=Util.GetApplicationPath()%> to getruntime absolute resource path.


change the <%=Util.GetApplicationPath()%> to<%# Util.GetApplicationPath()%> and I think you will get your desired results...I ran into the same issue with a project I was working ...