ASP.net fast code search
Only asp.net code search
Re: jQuery inside Usercontrol
leroylll

[quote user="alaa9jo"]

The problem is with using the multiview and updatepanel(the source is the updatepanel),to make things work fine you need a full postback (so the registered JS get executed),but since you need the updatepanel,then we have to deal with the multiview..that's why I hate multiview.

But I found a way...Cool

first,do you remember the JS block that we were adding in ListView_Transfer? well..remove it,all of it,we no longer need any js blocks in that control at all,then add this block in page_load of ListView_Transfer (the usercontrol):


  1. Dim myscript As StringBuilder = New StringBuilder()  
  2.         myscript.Append("$(function() {")  
  3.         myscript.Append("MakeItemsDraggable('" & gallery.ClientID & "');")  
  4.         myscript.Append("MakeItemsDraggable('" & trash.ClientID & "');")  
  5.         myscript.Append("MakeItemsDroppable('" & gallery.ClientID & "', '" & trash.ClientID & "', 'custom-state-active', '" & galleryData.ClientID & "', '" & trashData.ClientID & "', true);")  
  6.         myscript.Append("MakeItemsDroppable('" & trash.ClientID & "', '" & gallery.ClientID & "', 'ui-state-highlight', '" & galleryData.ClientID & "', '" & trashData.ClientID & "', false);")  
  7.         myscript.Append("ResolveIconsBehaviorWithEvent('" & gallery.ClientID & "', '" & trash.ClientID & "', '" & galleryData.ClientID & "', '<" & trashData.ClientID & "');")  
  8.         myscript.Append("});")  
  9.         Me.Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), Guid.NewGuid().ToString(), myscript.ToString(), True)  
  10.         ScriptManager.RegisterClientScriptBlock(MeMe.GetType(), Guid.NewGuid().ToString(), myscript.ToString(), True)  


Of course,you will have to modify it to make it work (the names of your controls are different than in this code,right?)



[/quote]


Hi,

I think there are some scripts missing right?

On async postback, the items all move back to their initial loaded state.

Please kindly assist.

Best Regards,

leroylll

Re: Window.print() - need help with RegisterClientScriptBlock
nb

you marked answer for your reply. 

Re: Window.print() - need help with RegisterClientScriptBlock
lusty_learner

Curious to know can we make the code behind page event run using this

<asp:Button ID="ASPxBtn4D" runat="server" OnClientClick="window.print(); return false;" Text="Button" />

code?

Re: Window.print() - need help with RegisterClientScriptBlock
lusty_learner

This works Thanks!

Re: Window.print() - need help with RegisterClientScriptBlock
nb

or try this

 protected void ASPxBtn4D_Click(object sender, EventArgs e)
        {
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "Test", "window.print()", true);   
        }


aspx code

        <asp:Button ID="ASPxBtn4D" runat="server"  Text="Button" OnClick="ASPxBtn4D_Click" />


 

Re: Window.print() - need help with RegisterClientScriptBlock
nb

 try this

 <asp:Button ID="ASPxBtn4D" runat="server" OnClientClick="window.print(); return false;" Text="Button" />


 

Window.print() - need help with RegisterClientScriptBlock
lusty_learner

Hi,


  I have an aspx button on my .aspx page when users click on that button I should save some information to the database and the same time users would like to print the page as is. I am good with the saving info into the datbase but no luck with the javascript that I am trying to get working to print the page. Here is what I have but it doesn't seem like working.

protected void ASPxBtn4D_Click(object sender, EventArgs e)
    {
           
        StringBuilder sb = new StringBuilder();
        sb.Append("<script language='JavaScript'>");
        sb.AppendFormat("window.print");
        sb.Append("</script>");
         Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Test", sb.ToString(), true);

    }

Not sure if I am missing some thing.

Can some one please help me here.


Thanks,

L


Problem with Google Map API and javascript getElementById
dean@maniontech.com

I'm trying to get the Google map API to work with ASP.NET. I got it working on an HTML page but it does not work on a ASP.NET master page/content page. The problem seems to be  getElementById not finding a div assigned to an ID. Here is the div:

<asp:Panel ID="Panel1" CssClass="intro-txt" runat="server" HorizontalAlign="Center">
      <div id="map_canvas" style="width: 550px; height: 400px"></div>
    </asp:Panel>

Here is the javascript:

function initialize(){

if (GBrowserIsCompatible()) {
            var map = new GMap2(document.getElementById("map_canvas"));
            map.setCenter(new GLatLng(39.039153, -94.586942), 9);
            map.setUIToDefault();

}

}

Here is the where I'm firing off the script:

protected void Page_Load(object sender, EventArgs e)
    {
        ClientScript.RegisterClientScriptBlock(GetType(), "Javascript",
     "<script>initialize();</script>");

    
    }

The script is firing but the getElementByid seems to be failing. I tested it by itself and its returning a null. Is the div id not available on Page_Load???. Seemed to be the logical place since the HTML verson was using <Body onload="initialize()" I've written a lot of javascript for onclick events but this is the first one I've tried  at Page_Load.

Any Ideas?

Dean


Re: Modal popup pops up twice
Puneri_25

 I tried following code (behaviourID and ClientID both). but getting JS Error 'object expected'

on Hide().

Dim mpe As ModalPopupExtender = Me.grdFavorites.Rows(e.RowIndex).FindControl("ModalPopupExtender2")
            Dim sb As New StringBuilder
            sb.Append("<script type = 'text/javascript'>alert('Asset has been removed from favorites list');")
            sb.Append("$find('")
            sb.Append(mpe.BehaviorID) 'mpe.ClientID 
            sb.Append("');hide();")
            sb.Append("</script>")

            ScriptManager.RegisterClientScriptBlock(Me, _
                                        Me.[GetType](), _
                                        "alert", _
                                        sb.ToString(), _
                                        False)


 

 

Re: How to display the message if the records are updated successfully.
alnaji

this is your code with little changes

Imports System  
Imports System.Web  
Imports System.Web.UI  
Imports System.Web.UI.WebControls  
Imports System.Data  
Imports System.Data.OracleClient  
Imports System.Configuration  
   
Partial Class _Default  
     Inherits System.Web.UI.Page  
   
    Protected Sub ResetPassword_OnClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ResetPasswordButton.Click  
        Dim oraConn As New OracleConnection  
        Dim oraCmd As New OracleCommand  
         Dim ds As New DataSet  
        Dim strConnection As String  
        Dim oraAdapter As New OracleDataAdapter  

Try  
             'Get connection string from Web.Config  
            strConnection = ConfigurationManager.AppSettings("ConnectionString")  
            oraConn = New OracleConnection(strConnection)  
           oraCmd = New OracleCommand(" update E0011 set password='ahlnhTczpihljbIn' where user_id='S707553'", oraConn)  
            oraConn.Open()  
             GridView1.DataSource = oraCmd.ExecuteReader()  
             Label1.Text = "Password has been reset."  
             Me.GridView1.DataBind()  
             Me.Label1.DataBind()  

 'display alert if it is updated
      Me.ClientScript.RegisterClientScriptBlock(Me.GetType(),"clientScript", "window.alert('updated')", true)

 Catch ex As Exception  

'Display alert if it is not updated
            Me.ClientScript.RegisterClientScriptBlock(Me.GetType(),"clientScript", "window.alert('Not updated')", true)
 Finally  
             oraConn.Close()  
         End Try  
   
    
      End Sub  
 End Class

Good luck