الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كيف يمكن استدعاء كود javascript من داخل Ajax و Timer

بدأه mamababadada في 26 مارس 2013 · 4 رد · 689 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم لدي كود جافا سكربت يقوم بتثبيت مؤشر الكتابه عند نهاية السطر الكود يعمل سليم بدون استخدام UpdatePanel  لكن مع استخدامها لم استطيع معرفة كيفية استدعاء الكود .

 

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>


<script type="text/javascript">
<!--
function txtpostion(elementRef)
{ 
      
      var name = document.getElementById('<%= TextBox1.ClientID %>').value;
      document.getElementById('<%= TextBox1.ClientID %>').value = name;      
      setCursorPositionToEnd('<%= TextBox1.ClientID %>');
       
}


function setCursorPositionToEnd(elementId)
{
 var elementRef = document.getElementById(elementId);
 var cursorPosition = document.getElementById(elementId).value.length;
 

 if ( elementRef != null )
 {
  if ( elementRef.createTextRange )
  {
   var textRange = elementRef.createTextRange(); 
   
   textRange.move('character', cursorPosition);
   textRange.select();
  }
  else
  {
   if ( elementRef.selectionStart )
   {
    elementRef.focus();
    elementRef.setSelectionRange(cursorPosition, cursorPosition);
   }
   else
   {
    elementRef.focus();
   }
  }
 }
}
// -->
</script>
</head>


<body onload="javascript:txtpostion(this);">




    <form id="form1" runat="server">
    <div>
        
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        
        
        
        
     <asp:UpdatePanel ID="UpdatePanel1" runat="server">
     <ContentTemplate>
         
     
     <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
            
  

    
    <p>
    <asp:TextBox ID="TextBox1" runat="server" Height="45px" Width="457px" ></asp:TextBox>
    </p>       
     
    <asp:Timer ID="Timer1" runat="server" Interval="1500"></asp:Timer>
        
    </ContentTemplate>
    </asp:UpdatePanel>
    
    </div>
    </form>
</body>
</html>

Many of life’s failures are people who did not realize how close they were to success when they gave up

Thomas Edison

#2

عدل هذا السطر فقط . 

 

 

 

 

 <asp:Timer ID="Timer1" runat="server" Interval="1500"></asp:Timer>

 

 

 

ليصبح هكذا 

 

 

 

 <asp:Timer ID="Timer1" runat="server" Interval="1500" OnTick="javascript:txtpostion(this);"></asp:Timer>

 

تحياتي

OMANI FOR EVER

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

post-12787-12780191801974.jpg

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

#3

حصلت على هذه الرساله :

 

Server Error in '/Wtt' Application. Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1026: ) expected

Source Error:

 

 

 

Line 59: <asp:UpdatePanel ID="UpdatePanel1" runat="server"> Line 60: <ContentTemplate> Line 61: <asp:Timer ID="Timer1" runat="server" Interval="1500" OnTick="javascript:txtpostion(this);"></asp:Timer> Line 62: Line 63: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>


Source File: c:\Inetpub\wwwroot\Wtt\Default3.aspx    Line: 61

 

 




 

post-218064-0-66364300-1364455815_thumb.

تم تعديل هذه المشاركة بواسطة mamababadada في 28 مارس 2013 في 10:30

Many of life’s failures are people who did not realize how close they were to success when they gave up

Thomas Edison

#4

ماهو المحرر الذي تستخدمه؟؟

OMANI FOR EVER

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

post-12787-12780191801974.jpg

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

#5

Microsoft Visual Studio 2008  :huh:

Many of life’s failures are people who did not realize how close they were to success when they gave up

Thomas Edison

مواضيع مشابهة